ShynBui commited on
Commit
3efc81d
1 Parent(s): 11a26b5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -60
app.py CHANGED
@@ -24,66 +24,6 @@ parent_document_retrieve = load_the_parent_document_retrieve()
24
  # tokenizer = AutoTokenizer.from_pretrained("ShynBui/vie_qa", token=os.environ.get("HF_TOKEN"))
25
  # model = AutoModelForQuestionAnswering.from_pretrained("ShynBui/vie_qa", token=os.environ.get("HF_TOKEN"))
26
 
27
- os.environ["OPENAI_API_KEY"] = "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"
28
-
29
- llm = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=1,openai_api_key=os.environ["OPENAI_API_KEY"])
30
- llm_long = ChatOpenAI(model="gpt-3.5-turbo-0125", temperature=1,max_tokens=1024, openai_api_key=os.environ["OPENAI_API_KEY"])
31
-
32
- os.environ['PROMPT'] = '''
33
- You are a helpful assistant specializing in answering questions related to academics and admissions at Ho Chi Minh City Open University.
34
- Based on information from "Context", give answers and suggest related topics.
35
-
36
- 1. Read the context carefully and remember concepts, terms or ideas.
37
-
38
- 2. Check if the context information can answer the question.
39
-
40
- 3. If the context information can answer the question, explain the answer in detail, don't try to make up an answer. If the context information can not answer the question, present the results as the following string: "I don't have information about the data".
41
-
42
- 4. Present the results in Vietnamese. Format into a string that includes only the answer to the question.
43
-
44
- Example:
45
- Context: A vector store-based retrieval engine is a system designed to retrieve documents based on their similarity to a query. This system is based on two main components:
46
- Vector store-backed retriever: A database specifically designed to store and manage high-dimensional vectors. These vectors represent the “meaning” or content of the document in numerical form. The vector store allows efficient retrieval of documents based on their vector similarity to a given query vector.
47
- Question: What is vector store-backed retriever?
48
- Output: Vector store-backed retriever is a database specifically designed to store and manage high-dimensional vectors. These vectors represent the “meaning” or content of the document in numerical form. The vector store allows efficient retrieval of documents based on their vector similarity to a given query vector.
49
-
50
- '''
51
-
52
- os.environ['SUMARY_MESSAGE_PROMPT'] = '''
53
- You are a professional summarizer in summarizing the conversation between the user and the AI. Your task is to summarize the content of the conversation from "History", the goal is for the language model to understand the context and hidden entities of the question so that it can give the most accurate answer. .
54
-
55
- 1. Read the context carefully and memorize concepts, terms or ideas.
56
-
57
- 2. Check which entity the conversation is talking about, and what issues are related to the entity.
58
-
59
- 3. Bring up the last mentioned entity in the conversation, so the AI can continue the conversation with the user.
60
-
61
- 4. Present the results in Vietnamese.
62
-
63
- History:
64
- Human: Ai là Hiệu trưởng của trường Đại học Mở TP.HCM?
65
- AI: Hiệu trưởng của trường Đại học Mở Thành phố Hồ Chí Minh là GS.TS. Nguyễn Minh Hà.
66
- Output: Cuộc trò chuyện trước đó nói về GS.TS. Nguyễn Minh Hà là hiệu trưởng của trường Đại học Mở TP.HCM.
67
-
68
- '''
69
-
70
- os.environ['NEW_QUESTION_PROMPT'] = '''
71
- You are an effective assistant specializing in answering questions related to academics and admissions at Ho Chi Minh City Open University. Answer all questions to the best of your ability. Based on "Summary" and "Questions" below. \
72
- 1. Read "Summary" and "Question" carefully, check whether the question is related to the previous summary paragraph by examining the entities.
73
- 2. Decontextualize the "Question" by adding necessary modifiers to nouns or entire sentences and replacing pronouns (e.g. "it", "he", "she", "they" , "this", "that") by the full names of the entities they refer to.
74
- 3. Format the question so that the tracking system can find the answer from the question. Don't try to ask the opposite question.
75
- 4. Present results in Vietnamese. Format into a string that includes only the recreated question.
76
-
77
- Example:
78
- Summary: Trong cuộc trò chuyện, người dùng hỏi về Hiệu trưởng của trường Đại học Mở TP.HCM và AI đã trả lời rằng GS.TS. Nguyễn Minh Hà là Hiệu trưởng của trường này.
79
- Question: Ông ấy có trách nhiệm gì
80
- Output: Hiệu trưởng của trường Đại học Mở TP.HCM có trách nhiệm gì?
81
-
82
- Summary: Trong cuộc trò chuyện, người dùng hỏi về Hiệu trưởng của trường Đại học Mở TP.HCM và AI đã trả lời rằng GS.TS. Nguyễn Minh Hà là Hiệu trưởng của trường này.
83
- Question: Trách nhiệm của sinh viên là gì
84
- Output: Trách nhiệm của sinh viên trường Đại học Mở TP.HCM là gì?
85
-
86
- '''
87
 
88
 
89
  def greet3(quote, history):
 
24
  # tokenizer = AutoTokenizer.from_pretrained("ShynBui/vie_qa", token=os.environ.get("HF_TOKEN"))
25
  # model = AutoModelForQuestionAnswering.from_pretrained("ShynBui/vie_qa", token=os.environ.get("HF_TOKEN"))
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
 
29
  def greet3(quote, history):