Prakh24s commited on
Commit
65e117d
·
verified ·
1 Parent(s): f518c40

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -5
app.py CHANGED
@@ -13,6 +13,11 @@ current_id = 0
13
  chat_history = []
14
  chat_metadata = []
15
  history_ids = []
 
 
 
 
 
16
 
17
  def generate_response(messages):
18
  model_name = os.getenv("MODEL_NAME")
@@ -24,11 +29,7 @@ def generate_response(messages):
24
 
25
  def chat_interface(user_input):
26
  global current_id
27
- chroma_client = chromadb.Client()
28
- embedding_function = OpenAIEmbeddingFunction(api_key=os.getenv("OPENAI_KEY"), model_name=os.getenv("EMBEDDING_MODEL"))
29
- collection = chroma_client.create_collection(name="conversations", embedding_function=embedding_function)
30
-
31
- messages = [{"role": "system", "content": "You are a kind and friendly chatbot"}]
32
  results = collection.query(query_texts=[user_input], n_results=2)
33
  for res in results['documents'][0]:
34
  messages.append({"role": "user", "content": f"previous chat: {res}"})
 
13
  chat_history = []
14
  chat_metadata = []
15
  history_ids = []
16
+ chroma_client = chromadb.Client()
17
+ embedding_function = OpenAIEmbeddingFunction(api_key=os.getenv("OPENAI_KEY"), model_name=os.getenv("EMBEDDING_MODEL"))
18
+ collection = chroma_client.create_collection(name="conversations", embedding_function=embedding_function)
19
+
20
+ messages = [{"role": "system", "content": "You are a kind and friendly chatbot"}]
21
 
22
  def generate_response(messages):
23
  model_name = os.getenv("MODEL_NAME")
 
29
 
30
  def chat_interface(user_input):
31
  global current_id
32
+
 
 
 
 
33
  results = collection.query(query_texts=[user_input], n_results=2)
34
  for res in results['documents'][0]:
35
  messages.append({"role": "user", "content": f"previous chat: {res}"})