Merge pull request #89 from StampyAI/separate-src

Move API files to a src folder
This commit is contained in:
TJ Porter
2023-09-04 22:13:22 -05:00
committed by GitHub
14 changed files with 467 additions and 424 deletions
+1
View File
@@ -4,6 +4,7 @@ verify_ssl = true
name = "pypi"
[packages]
stampy-chat = {editable = true, path = "."}
# ---- <flask stuff> ----
flask = "==1.1.2"
gunicorn = "==20.0.4"
+424 -409
View File
File diff suppressed because it is too large Load Diff
+5 -5
View File
@@ -5,9 +5,9 @@ import dataclasses
import json
import re
from env import PINECONE_INDEX, log
from get_blocks import get_top_k_blocks
from chat import talk_to_robot, talk_to_robot_simple
from stampy_chat.env import PINECONE_INDEX, FLASK_PORT, log
from stampy_chat.get_blocks import get_top_k_blocks
from stampy_chat.chat import talk_to_robot, talk_to_robot_simple
# ---------------------------------- web setup ---------------------------------
@@ -73,10 +73,10 @@ def human(id):
# ⬇️
# <a href=\"https://stampy.ai/?state=6207&question=What%20is%20%22superintelligence%22%3F\">
text = re.sub(r'<a href=\\"/\?state=(\d+.*)\\">', r'<a href=\"https://aisafety.info/?state=\1\\">', r.text)
return Response(text, mimetype='application/json')
# ------------------------------------------------------------------------------
if __name__ == '__main__':
app.run(debug=True, port=3000)
app.run(debug=True, port=FLASK_PORT)
+2 -3
View File
@@ -5,8 +5,8 @@ import json
from datetime import datetime
sys.path = [str(Path(__file__).parent.parent)] + sys.path
from env import PINECONE_INDEX
from chat import talk_to_robot_simple, set_debug_print
from stampy_chat.env import PINECONE_INDEX
from stampy_chat.chat import talk_to_robot_simple, set_debug_print
set_debug_print(False)
# read in a list of questions from questions.csv
@@ -51,4 +51,3 @@ with open(Path(__file__).parent / 'data/answers.csv', 'w') as f:
citation = [x.strip() for x in citation]
citation = [x for x in citation if x != '']
writer.writerow([c, ' --- '.join(citation)])
+25
View File
@@ -0,0 +1,25 @@
from setuptools import setup, find_packages
setup(
name='Stampy-chat',
version='0.1',
packages=find_packages(where="src"),
package_dir={"": "src"},
install_requires=[
'flask',
'gunicorn',
'jinja2',
'markupsafe',
'itsdangerous',
'werkzeug',
'flask-cors',
'openai',
'numpy',
'tenacity',
'tiktoken',
'pinecone-client',
'python-dotenv',
'discord-webhook',
'requests'
],
)
View File
+4 -3
View File
@@ -1,7 +1,4 @@
# ------------------------------- env, constants -------------------------------
from followups import multisearch_authored
from get_blocks import get_top_k_blocks, Block
from dataclasses import asdict
from typing import List, Dict, Callable
import openai
@@ -9,6 +6,10 @@ import re
import tiktoken
import time
from stampy_chat.followups import multisearch_authored
from stampy_chat.get_blocks import get_top_k_blocks, Block
# OpenAI models
EMBEDDING_MODEL = "text-embedding-ada-002"
COMPLETIONS_MODEL = "gpt-3.5-turbo"
@@ -15,6 +15,8 @@ PINECONE_API_KEY = os.environ.get('PINECONE_API_KEY')
LOGGING_URL = os.environ.get('LOGGING_URL')
PINECONE_INDEX = None
FLASK_PORT = int(os.environ.get('FLASK_PORT', '3001'))
openai.api_key = OPENAI_API_KEY # non-optional
# Only init pinecone if we have an env value for it.
+1 -2
View File
@@ -1,5 +1,3 @@
const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:3000";
import Head from "next/head";
import React from "react";
import { type NextPage } from "next";
@@ -11,6 +9,7 @@ import Header from "../header";
import { SearchBox, Followup } from "../searchbox";
import logo from "../logo.svg"
import { GlossarySpan } from "../glossary";
import { API_URL } from "../settings"
type Citation = {
title: string;
+1 -2
View File
@@ -1,11 +1,10 @@
const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:3000";
import { type NextPage } from "next";
import React from "react";
import Head from "next/head";
import Header from "../header";
import { SearchBox, Followup } from "../searchbox";
import { useState } from "react";
import { API_URL } from "../settings"
const Semantic: NextPage = () => {
+2
View File
@@ -0,0 +1,2 @@
export const API_URL = process.env.NEXT_PUBLIC_API_URL || "http://127.0.0.1:3001";
export const STAMPY_URL = process.env.STAMPY_URL || "https://aisafety.info"