test fix
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import os
|
|
2 |
import time
|
3 |
import gradio as gr
|
4 |
|
|
|
5 |
from groq import Groq
|
6 |
from pinecone import Pinecone, ServerlessSpec
|
7 |
from semantic_router.encoders import HuggingFaceEncoder
|
@@ -21,12 +22,12 @@ if index_name not in [i["name"] for i in pc.list_indexes()]:
|
|
21 |
|
22 |
index = pc.Index(index_name)
|
23 |
|
24 |
-
def get_docs(query: str, top_k: int) ->
|
25 |
xq = encoder([query])
|
26 |
res = index.query(vector=xq, top_k=top_k, include_metadata=True)
|
27 |
return [x["metadata"]['content_snippet'] for x in res["matches"]]
|
28 |
|
29 |
-
def generate(query: str, history):
|
30 |
if not history:
|
31 |
system_message = (
|
32 |
"You are a friendly and knowledgeable New Yorker who loves sharing recommendations about the city. "
|
|
|
2 |
import time
|
3 |
import gradio as gr
|
4 |
|
5 |
+
from typing import List, Tuple
|
6 |
from groq import Groq
|
7 |
from pinecone import Pinecone, ServerlessSpec
|
8 |
from semantic_router.encoders import HuggingFaceEncoder
|
|
|
22 |
|
23 |
index = pc.Index(index_name)
|
24 |
|
25 |
+
def get_docs(query: str, top_k: int) -> List[str]:
|
26 |
xq = encoder([query])
|
27 |
res = index.query(vector=xq, top_k=top_k, include_metadata=True)
|
28 |
return [x["metadata"]['content_snippet'] for x in res["matches"]]
|
29 |
|
30 |
+
def generate(query: str, history: List[Tuple[str, str]]) -> str:
|
31 |
if not history:
|
32 |
system_message = (
|
33 |
"You are a friendly and knowledgeable New Yorker who loves sharing recommendations about the city. "
|