Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -42,467 +42,6 @@
|
|
42 |
# if __name__ == "__main__":
|
43 |
# demo.launch()
|
44 |
|
45 |
-
# import subprocess
|
46 |
-
|
47 |
-
# # Run the Bash script that installs dependencies and runs the app
|
48 |
-
# subprocess.run(['./run.sh'])
|
49 |
-
|
50 |
-
# # Rest of your application code can go here
|
51 |
-
# import subprocess
|
52 |
-
# import os
|
53 |
-
|
54 |
-
# # Ensure the run.sh script has executable permissions
|
55 |
-
# # subprocess.run(['chmod', '+x', './run.sh'])
|
56 |
-
|
57 |
-
# # Run the Bash script that installs dependencies and runs the app
|
58 |
-
# # subprocess.run(['./run.sh'])
|
59 |
-
|
60 |
-
# import gradio as gr
|
61 |
-
# from langchain_openai import ChatOpenAI
|
62 |
-
# from langchain.prompts import PromptTemplate
|
63 |
-
# from langchain.memory import ConversationBufferMemory
|
64 |
-
# from langchain.chains import RunnableSequence
|
65 |
-
|
66 |
-
# # Set OpenAI API Key
|
67 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
68 |
-
|
69 |
-
# # Define the template for the chatbot's response
|
70 |
-
# template = """You are a helpful assistant to answer all user queries.
|
71 |
-
# {chat_history}
|
72 |
-
# User: {user_message}
|
73 |
-
# Chatbot:"""
|
74 |
-
|
75 |
-
# # Define the prompt template
|
76 |
-
# prompt = PromptTemplate(
|
77 |
-
# input_variables=["chat_history", "user_message"],
|
78 |
-
# template=template
|
79 |
-
# )
|
80 |
-
|
81 |
-
# # Initialize conversation memory
|
82 |
-
# memory = ConversationBufferMemory(memory_key="chat_history")
|
83 |
-
|
84 |
-
# # Define the LLM (language model)
|
85 |
-
# llm = ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo")
|
86 |
-
|
87 |
-
# # Define the chain using RunnableSequence (replace LLMChain)
|
88 |
-
# llm_chain = prompt | llm # Chaining the prompt and the LLM
|
89 |
-
|
90 |
-
# # Function to get chatbot response
|
91 |
-
# def get_text_response(user_message, history):
|
92 |
-
# inputs = {"chat_history": history, "user_message": user_message}
|
93 |
-
# response = llm_chain(inputs)
|
94 |
-
# return response['text']
|
95 |
-
|
96 |
-
# # Create a Gradio chat interface
|
97 |
-
# demo = gr.Interface(fn=get_text_response, inputs="text", outputs="text")
|
98 |
-
|
99 |
-
# if __name__ == "__main__":
|
100 |
-
# demo.launch()
|
101 |
-
|
102 |
-
|
103 |
-
# import os
|
104 |
-
# import gradio as gr
|
105 |
-
# from langchain_openai import ChatOpenAI
|
106 |
-
# from langchain.prompts import PromptTemplate
|
107 |
-
# from langchain.memory import ConversationBufferMemory
|
108 |
-
# from langchain.chains import LLMChain
|
109 |
-
|
110 |
-
# # Set OpenAI API Key
|
111 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
112 |
-
|
113 |
-
# # Define the template for the chatbot's response
|
114 |
-
# template = """You are a helpful assistant to answer all user queries.
|
115 |
-
# {chat_history}
|
116 |
-
# User: {user_message}
|
117 |
-
# Chatbot:"""
|
118 |
-
|
119 |
-
# # Define the prompt template
|
120 |
-
# prompt = PromptTemplate(
|
121 |
-
# input_variables=["chat_history", "user_message"],
|
122 |
-
# template=template
|
123 |
-
# )
|
124 |
-
|
125 |
-
# # Initialize conversation memory
|
126 |
-
# memory = ConversationBufferMemory(memory_key="chat_history")
|
127 |
-
|
128 |
-
# # Define the LLM (language model) and chain
|
129 |
-
# llm = ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo")
|
130 |
-
# llm_chain = LLMChain(
|
131 |
-
# llm=llm,
|
132 |
-
# prompt=prompt,
|
133 |
-
# verbose=True,
|
134 |
-
# memory=memory,
|
135 |
-
# )
|
136 |
-
|
137 |
-
# # Function to get chatbot response
|
138 |
-
# def get_text_response(user_message, history):
|
139 |
-
# response = llm_chain.predict(user_message=user_message)
|
140 |
-
# return response
|
141 |
-
|
142 |
-
# # Create a Gradio chat interface
|
143 |
-
# demo = gr.Interface(fn=get_text_response, inputs="text", outputs="text")
|
144 |
-
|
145 |
-
# if __name__ == "__main__":
|
146 |
-
# demo.launch()
|
147 |
-
|
148 |
-
# import os
|
149 |
-
# import gradio as gr
|
150 |
-
# from langchain_openai import ChatOpenAI
|
151 |
-
# from langchain.prompts import PromptTemplate
|
152 |
-
# from langchain.memory import ConversationBufferMemory
|
153 |
-
# from langchain.schema import AIMessage, HumanMessage
|
154 |
-
# from langchain.chains import RunnableSequence
|
155 |
-
|
156 |
-
# # Set OpenAI API Key
|
157 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
158 |
-
|
159 |
-
# # Define the template for the chatbot's response
|
160 |
-
# template = """You are a helpful assistant to answer all user queries.
|
161 |
-
# {chat_history}
|
162 |
-
# User: {user_message}
|
163 |
-
# Chatbot:"""
|
164 |
-
|
165 |
-
# # Define the prompt template
|
166 |
-
# prompt = PromptTemplate(
|
167 |
-
# input_variables=["chat_history", "user_message"],
|
168 |
-
# template=template
|
169 |
-
# )
|
170 |
-
|
171 |
-
# # Initialize conversation memory (following migration guide)
|
172 |
-
# memory = ConversationBufferMemory(return_messages=True) # Use return_messages=True for updated usage
|
173 |
-
|
174 |
-
# # Define the LLM (language model)
|
175 |
-
# llm = ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo")
|
176 |
-
|
177 |
-
# # Create the RunnableSequence instead of LLMChain
|
178 |
-
# llm_sequence = prompt | llm # This pipelines the prompt into the language model
|
179 |
-
|
180 |
-
# # Function to get chatbot response
|
181 |
-
# def get_text_response(user_message, history):
|
182 |
-
# # Prepare the conversation history
|
183 |
-
# chat_history = [HumanMessage(content=user_message)]
|
184 |
-
|
185 |
-
# # Pass the prompt and history to the language model sequence
|
186 |
-
# response = llm_sequence.invoke({"chat_history": history, "user_message": user_message})
|
187 |
-
|
188 |
-
# return response
|
189 |
-
|
190 |
-
# # Create a Gradio chat interface
|
191 |
-
# demo = gr.Interface(fn=get_text_response, inputs="text", outputs="text")
|
192 |
-
|
193 |
-
# if __name__ == "__main__":
|
194 |
-
# demo.launch()
|
195 |
-
|
196 |
-
# import os
|
197 |
-
# import gradio as gr
|
198 |
-
# from langchain_openai import ChatOpenAI
|
199 |
-
# from langchain.prompts import PromptTemplate
|
200 |
-
# from langchain.memory import ConversationBufferMemory
|
201 |
-
# from langchain.schema import AIMessage, HumanMessage
|
202 |
-
# from langchain import Runnable # Using Runnable instead of RunnableSequence
|
203 |
-
|
204 |
-
# # Set OpenAI API Key
|
205 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
206 |
-
|
207 |
-
# # Define the template for the chatbot's response
|
208 |
-
# template = """You are a helpful assistant to answer all user queries.
|
209 |
-
# {chat_history}
|
210 |
-
# User: {user_message}
|
211 |
-
# Chatbot:"""
|
212 |
-
|
213 |
-
# # Define the prompt template
|
214 |
-
# prompt = PromptTemplate(
|
215 |
-
# input_variables=["chat_history", "user_message"],
|
216 |
-
# template=template
|
217 |
-
# )
|
218 |
-
|
219 |
-
# # Initialize conversation memory (following migration guide)
|
220 |
-
# memory = ConversationBufferMemory(return_messages=True) # Use return_messages=True for updated usage
|
221 |
-
|
222 |
-
# # Define the LLM (language model)
|
223 |
-
# llm = ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo")
|
224 |
-
|
225 |
-
# # Create the Runnable instead of RunnableSequence
|
226 |
-
# llm_runnable = Runnable(lambda inputs: prompt.format(**inputs)) | llm
|
227 |
-
|
228 |
-
# # Function to get chatbot response
|
229 |
-
# def get_text_response(user_message, history):
|
230 |
-
# # Prepare the conversation history
|
231 |
-
# chat_history = [HumanMessage(content=user_message)]
|
232 |
-
|
233 |
-
# # Pass the prompt and history to the language model sequence
|
234 |
-
# response = llm_runnable.invoke({"chat_history": history, "user_message": user_message})
|
235 |
-
|
236 |
-
# return response
|
237 |
-
|
238 |
-
# # Create a Gradio chat interface
|
239 |
-
# demo = gr.Interface(fn=get_text_response, inputs="text", outputs="text")
|
240 |
-
|
241 |
-
# if __name__ == "__main__":
|
242 |
-
# demo.launch()
|
243 |
-
|
244 |
-
# import os
|
245 |
-
# import subprocess
|
246 |
-
# import gradio as gr
|
247 |
-
|
248 |
-
# # Install necessary packages
|
249 |
-
# subprocess.check_call(["pip", "install", "-U", "langchain-openai", "gradio", "langchain-community"])
|
250 |
-
|
251 |
-
# from langchain_openai import ChatOpenAI
|
252 |
-
# from langchain.prompts import PromptTemplate
|
253 |
-
# from langchain.chains import LLMChain
|
254 |
-
# from langchain.memory import ConversationBufferMemory
|
255 |
-
|
256 |
-
# # Set OpenAI API Key
|
257 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
258 |
-
|
259 |
-
# # Define the template for the chatbot's response
|
260 |
-
# template = """You are a helpful assistant to answer all user queries.
|
261 |
-
# {chat_history}
|
262 |
-
# User: {user_message}
|
263 |
-
# Chatbot:"""
|
264 |
-
|
265 |
-
# # Define the prompt template
|
266 |
-
# prompt = PromptTemplate(
|
267 |
-
# input_variables=["chat_history", "user_message"],
|
268 |
-
# template=template
|
269 |
-
# )
|
270 |
-
|
271 |
-
# # Initialize conversation memory
|
272 |
-
# memory = ConversationBufferMemory(memory_key="chat_history")
|
273 |
-
|
274 |
-
# # Define the LLM chain with the ChatOpenAI model and conversation memory
|
275 |
-
# llm_chain = LLMChain(
|
276 |
-
# llm=ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo"), # Use 'model' instead of 'model_name'
|
277 |
-
# prompt=prompt,
|
278 |
-
# verbose=True,
|
279 |
-
# memory=memory,
|
280 |
-
# )
|
281 |
-
|
282 |
-
# # Function to get chatbot response
|
283 |
-
# def get_text_response(user_message, history):
|
284 |
-
# # Prepare the conversation history
|
285 |
-
# chat_history = history + [f"User: {user_message}"]
|
286 |
-
# response = llm_chain.predict(user_message=user_message, chat_history=chat_history)
|
287 |
-
# return response
|
288 |
-
|
289 |
-
# # Create a Gradio chat interface
|
290 |
-
# demo = gr.Interface(fn=get_text_response, inputs="text", outputs="text")
|
291 |
-
|
292 |
-
# if __name__ == "__main__":
|
293 |
-
# demo.launch()
|
294 |
-
|
295 |
-
# import os
|
296 |
-
# import subprocess
|
297 |
-
# import gradio as gr
|
298 |
-
|
299 |
-
# # Install necessary packages
|
300 |
-
# subprocess.check_call(["pip", "install", "-U", "langchain-openai", "gradio", "langchain-community"])
|
301 |
-
|
302 |
-
# from langchain_openai import ChatOpenAI
|
303 |
-
# from langchain.prompts import PromptTemplate
|
304 |
-
# from langchain.memory import ConversationBufferMemory
|
305 |
-
# from langchain.chains import Runnable, RunnableSequence
|
306 |
-
|
307 |
-
# # Set OpenAI API Key
|
308 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
309 |
-
|
310 |
-
# # Define the template for the chatbot's response
|
311 |
-
# template = """You are a helpful assistant to answer all user queries.
|
312 |
-
# {chat_history}
|
313 |
-
# User: {user_message}
|
314 |
-
# Chatbot:"""
|
315 |
-
|
316 |
-
# # Define the prompt template
|
317 |
-
# prompt = PromptTemplate(
|
318 |
-
# input_variables=["chat_history", "user_message"],
|
319 |
-
# template=template
|
320 |
-
# )
|
321 |
-
|
322 |
-
# # Initialize conversation memory
|
323 |
-
# memory = ConversationBufferMemory(memory_key="chat_history")
|
324 |
-
|
325 |
-
# # Define the runnable sequence
|
326 |
-
# chatbot_runnable = RunnableSequence(prompt | ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo"))
|
327 |
-
|
328 |
-
# # Function to get chatbot response
|
329 |
-
# def get_text_response(user_message, history=None):
|
330 |
-
# # Ensure history is a list
|
331 |
-
# if history is None:
|
332 |
-
# history = []
|
333 |
-
|
334 |
-
# # Prepare the conversation history
|
335 |
-
# chat_history = history + [f"User: {user_message}"]
|
336 |
-
# response = chatbot_runnable.invoke({"chat_history": "\n".join(chat_history), "user_message": user_message})
|
337 |
-
|
338 |
-
# return response
|
339 |
-
|
340 |
-
# # Create a Gradio chat interface
|
341 |
-
# demo = gr.Interface(fn=get_text_response, inputs=["text", "state"], outputs="text")
|
342 |
-
|
343 |
-
# if __name__ == "__main__":
|
344 |
-
# demo.launch()
|
345 |
-
|
346 |
-
# import os
|
347 |
-
# import subprocess
|
348 |
-
# import gradio as gr
|
349 |
-
|
350 |
-
# # Install necessary packages
|
351 |
-
# subprocess.check_call(["pip", "install", "-U", "langchain-openai", "gradio", "langchain-community"])
|
352 |
-
|
353 |
-
# from langchain_openai import ChatOpenAI
|
354 |
-
# from langchain.prompts import PromptTemplate
|
355 |
-
# from langchain.memory import ConversationBufferMemory
|
356 |
-
|
357 |
-
# # Set OpenAI API Key
|
358 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
359 |
-
|
360 |
-
# # Define the template for the chatbot's response
|
361 |
-
# template = """You are a helpful assistant to answer all user queries.
|
362 |
-
# {chat_history}
|
363 |
-
# User: {user_message}
|
364 |
-
# Chatbot:"""
|
365 |
-
|
366 |
-
# # Define the prompt template
|
367 |
-
# prompt = PromptTemplate(
|
368 |
-
# input_variables=["chat_history", "user_message"],
|
369 |
-
# template=template
|
370 |
-
# )
|
371 |
-
|
372 |
-
# # Initialize conversation memory
|
373 |
-
# memory = ConversationBufferMemory(memory_key="chat_history")
|
374 |
-
|
375 |
-
# # Function to get chatbot response
|
376 |
-
# def get_text_response(user_message, history=None):
|
377 |
-
# # Ensure history is a list
|
378 |
-
# if history is None:
|
379 |
-
# history = []
|
380 |
-
|
381 |
-
# # Prepare the conversation history
|
382 |
-
# chat_history = history + [f"User: {user_message}"]
|
383 |
-
# llm = ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo")
|
384 |
-
# response = llm({"chat_history": "\n".join(chat_history), "user_message": user_message})
|
385 |
-
|
386 |
-
# return response['choices'][0]['message']['content']
|
387 |
-
|
388 |
-
# # Create a Gradio chat interface
|
389 |
-
# demo = gr.Interface(fn=get_text_response, inputs=["text", "state"], outputs="text")
|
390 |
-
|
391 |
-
# if __name__ == "__main__":
|
392 |
-
# demo.launch()
|
393 |
-
|
394 |
-
# import os
|
395 |
-
# import subprocess
|
396 |
-
# import gradio as gr
|
397 |
-
|
398 |
-
# # Install necessary packages
|
399 |
-
# subprocess.check_call(["pip", "install", "-U", "langchain-openai", "gradio", "langchain-community"])
|
400 |
-
|
401 |
-
# from langchain_openai import ChatOpenAI
|
402 |
-
# from langchain.prompts import PromptTemplate
|
403 |
-
# from langchain.memory import ConversationBufferMemory
|
404 |
-
|
405 |
-
# # Set OpenAI API Key
|
406 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
407 |
-
|
408 |
-
# # Define the template for the chatbot's response
|
409 |
-
# template = """You are a helpful assistant to answer all user queries.
|
410 |
-
# {chat_history}
|
411 |
-
# User: {user_message}
|
412 |
-
# Chatbot:"""
|
413 |
-
|
414 |
-
# # Define the prompt template
|
415 |
-
# prompt = PromptTemplate(
|
416 |
-
# input_variables=["chat_history", "user_message"],
|
417 |
-
# template=template
|
418 |
-
# )
|
419 |
-
|
420 |
-
# # Initialize conversation memory
|
421 |
-
# memory = ConversationBufferMemory(memory_key="chat_history")
|
422 |
-
|
423 |
-
# # Function to get chatbot response
|
424 |
-
# def get_text_response(user_message, history=None):
|
425 |
-
# # Ensure history is a list
|
426 |
-
# if history is None:
|
427 |
-
# history = []
|
428 |
-
|
429 |
-
# # Prepare the conversation history
|
430 |
-
# chat_history = history + [f"User: {user_message}"]
|
431 |
-
# llm = ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo")
|
432 |
-
# response = llm({"chat_history": "\n".join(chat_history), "user_message": user_message})
|
433 |
-
|
434 |
-
# # Return the response and updated history
|
435 |
-
# return response['choices'][0]['message']['content'], chat_history
|
436 |
-
|
437 |
-
# # Create a Gradio chat interface
|
438 |
-
# demo = gr.Interface(
|
439 |
-
# fn=get_text_response,
|
440 |
-
# inputs=["text", "state"],
|
441 |
-
# outputs=["text", "state"],
|
442 |
-
# )
|
443 |
-
|
444 |
-
# if __name__ == "__main__":
|
445 |
-
# demo.launch()
|
446 |
-
|
447 |
-
# import os
|
448 |
-
# import subprocess
|
449 |
-
# import gradio as gr
|
450 |
-
|
451 |
-
# # Install necessary packages
|
452 |
-
# subprocess.check_call(["pip", "install", "-U", "langchain-openai", "gradio", "langchain-community"])
|
453 |
-
|
454 |
-
# from langchain_openai import ChatOpenAI
|
455 |
-
# from langchain.prompts import PromptTemplate
|
456 |
-
# from langchain.memory import ConversationBufferMemory
|
457 |
-
|
458 |
-
# # Set OpenAI API Key
|
459 |
-
# OPENAI_API_KEY = os.getenv('OPENAI_API_KEY')
|
460 |
-
|
461 |
-
# # Define the template for the chatbot's response
|
462 |
-
# template = """You are a helpful assistant to answer all user queries.
|
463 |
-
# {chat_history}
|
464 |
-
# User: {user_message}
|
465 |
-
# Chatbot:"""
|
466 |
-
|
467 |
-
# # Define the prompt template
|
468 |
-
# prompt = PromptTemplate(
|
469 |
-
# input_variables=["chat_history", "user_message"],
|
470 |
-
# template=template
|
471 |
-
# )
|
472 |
-
|
473 |
-
# # Initialize conversation memory
|
474 |
-
# memory = ConversationBufferMemory(memory_key="chat_history")
|
475 |
-
|
476 |
-
# # Function to get chatbot response
|
477 |
-
# def get_text_response(user_message, history=None):
|
478 |
-
# # Ensure history is a list
|
479 |
-
# if history is None:
|
480 |
-
# history = []
|
481 |
-
|
482 |
-
# # Prepare the conversation history
|
483 |
-
# chat_history = history + [f"User: {user_message}"]
|
484 |
-
|
485 |
-
# # Create the full prompt string
|
486 |
-
# full_prompt = prompt.format(chat_history="\n".join(chat_history), user_message=user_message)
|
487 |
-
|
488 |
-
# llm = ChatOpenAI(temperature=0.5, model="gpt-3.5-turbo")
|
489 |
-
|
490 |
-
# # Use the invoke method instead of __call__
|
491 |
-
# response = llm.invoke(full_prompt)
|
492 |
-
|
493 |
-
# # Return the response and updated history
|
494 |
-
# return response['choices'][0]['message']['content'], chat_history
|
495 |
-
|
496 |
-
# # Create a Gradio chat interface
|
497 |
-
# demo = gr.Interface(
|
498 |
-
# fn=get_text_response,
|
499 |
-
# inputs=["text", "state"],
|
500 |
-
# outputs=["text", "state"],
|
501 |
-
# )
|
502 |
-
|
503 |
-
# if __name__ == "__main__":
|
504 |
-
# demo.launch()
|
505 |
-
|
506 |
import os
|
507 |
import gradio as gr
|
508 |
from langchain.chat_models import ChatOpenAI
|
|
|
42 |
# if __name__ == "__main__":
|
43 |
# demo.launch()
|
44 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
import os
|
46 |
import gradio as gr
|
47 |
from langchain.chat_models import ChatOpenAI
|