momegas commited on
Commit
90793b1
·
1 Parent(s): ab83774

potential qurstions

Browse files
Files changed (1) hide show
  1. app.py +25 -1
app.py CHANGED
@@ -11,6 +11,7 @@ from langchain.llms import OpenAI
11
  from langchain.prompts import PromptTemplate
12
  from langchain.chat_models import ChatOpenAI
13
  from langchain.schema import AIMessage, HumanMessage, SystemMessage
 
14
 
15
  dotenv.load_dotenv()
16
 
@@ -44,7 +45,29 @@ embeddings = OpenAIEmbeddings()
44
  docsearch = Chroma.from_documents(texts, embeddings).as_retriever()
45
  chat = ChatOpenAI(temperature=0.9)
46
 
47
- import gradio as gr
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  with gr.Blocks() as demo:
50
  chatbot = gr.Chatbot()
@@ -70,5 +93,6 @@ with gr.Blocks() as demo:
70
 
71
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
72
 
 
73
  if __name__ == "__main__":
74
  demo.launch()
 
11
  from langchain.prompts import PromptTemplate
12
  from langchain.chat_models import ChatOpenAI
13
  from langchain.schema import AIMessage, HumanMessage, SystemMessage
14
+ import gradio as gr
15
 
16
  dotenv.load_dotenv()
17
 
 
45
  docsearch = Chroma.from_documents(texts, embeddings).as_retriever()
46
  chat = ChatOpenAI(temperature=0.9)
47
 
48
+
49
+ potential_questions = [
50
+ "ποια ειναι η εταιρεια;",
51
+ "ποια ειναι τα βηματα για ενα δανειο;",
52
+ "πως μπορω να κλεισω ραντεβου;",
53
+ "γιατι να ερθώ σε εσας;",
54
+ ]
55
+
56
+ for question in potential_questions:
57
+ result_docs = docsearch.get_relevant_documents(question)
58
+
59
+ print("Question: ", question)
60
+ print("-" * 20)
61
+
62
+ messages = [SystemMessage(content=system_message)]
63
+ human_message = HumanMessage(
64
+ content=PROMPT.format(context=result_docs[:3], question=question)
65
+ )
66
+ messages.append(human_message)
67
+ result = chat(messages)
68
+
69
+ print("Response: ", result, "\n")
70
+
71
 
72
  with gr.Blocks() as demo:
73
  chatbot = gr.Chatbot()
 
93
 
94
  msg.submit(respond, [msg, chatbot], [msg, chatbot])
95
 
96
+
97
  if __name__ == "__main__":
98
  demo.launch()