Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,9 +1,6 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import cohere
|
| 4 |
-
from langchain_community.document_loaders import JSONLoader
|
| 5 |
-
from langchain.embeddings.sentence_transformer import SentenceTransformerEmbeddings
|
| 6 |
-
from langchain_community.vectorstores import Chroma
|
| 7 |
|
| 8 |
|
| 9 |
COHERE_API_KEY = os.getenv("COHERE_API_KEY")
|
|
@@ -11,14 +8,6 @@ client = cohere.ClientV2(COHERE_API_KEY)
|
|
| 11 |
|
| 12 |
COHERE_MODEL = "command-r-plus"
|
| 13 |
|
| 14 |
-
embedding_function = SentenceTransformerEmbeddings(model_name="all-MiniLM-L6-v2")
|
| 15 |
-
|
| 16 |
-
loader = JSONLoader(file_path="games.json", jq_schema=".games[]", text_content=False)
|
| 17 |
-
documents = loader.load()
|
| 18 |
-
|
| 19 |
-
db = Chroma.from_documents(documents, embedding_function)
|
| 20 |
-
|
| 21 |
-
|
| 22 |
def respond(
|
| 23 |
message,
|
| 24 |
history: list[tuple[str, str]],
|
|
@@ -69,7 +58,6 @@ def respond(
|
|
| 69 |
model=COHERE_MODEL,
|
| 70 |
temperature=temperature,
|
| 71 |
max_tokens=max_tokens,
|
| 72 |
-
documents=db,
|
| 73 |
)
|
| 74 |
yield response.message.content[0].text
|
| 75 |
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import os
|
| 3 |
import cohere
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
|
| 6 |
COHERE_API_KEY = os.getenv("COHERE_API_KEY")
|
|
|
|
| 8 |
|
| 9 |
COHERE_MODEL = "command-r-plus"
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
def respond(
|
| 12 |
message,
|
| 13 |
history: list[tuple[str, str]],
|
|
|
|
| 58 |
model=COHERE_MODEL,
|
| 59 |
temperature=temperature,
|
| 60 |
max_tokens=max_tokens,
|
|
|
|
| 61 |
)
|
| 62 |
yield response.message.content[0].text
|
| 63 |
|