Spaces:
Runtime error
Runtime error
Commit
·
4dee166
1
Parent(s):
5e05672
correct defect
Browse files
app.py
CHANGED
|
@@ -65,7 +65,13 @@ import langchain
|
|
| 65 |
import asyncio
|
| 66 |
from playwright.async_api import async_playwright
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
|
| 70 |
async def start_playwright(question: str):
|
| 71 |
pw = await async_playwright().start()
|
|
@@ -489,6 +495,12 @@ chat = AzureChatOpenAI(
|
|
| 489 |
deployment_name=os.environ["deployment_name"],
|
| 490 |
temperature=0,
|
| 491 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 492 |
llm = chat
|
| 493 |
|
| 494 |
llm_math = LLMMathChain.from_llm(llm)
|
|
@@ -507,7 +519,22 @@ tools2 = [DB_Search2(), duckduckgo_tool2, wikipedia_tool2, python_tool2, math_to
|
|
| 507 |
|
| 508 |
# tools = load_tools(["Vector Database Search","Wikipedia Search","Python REPL","llm-math"], llm=llm)
|
| 509 |
|
| 510 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 511 |
|
| 512 |
# embeddings = OpenAIEmbeddings(deployment="model_embedding_2", chunk_size=15)
|
| 513 |
|
|
@@ -1119,7 +1146,7 @@ with gr.Blocks() as demo:
|
|
| 1119 |
|
| 1120 |
with gr.Column() as main2:
|
| 1121 |
title = gr.Markdown("""# <center> STLA BABY - YOUR FRIENDLY GUIDE
|
| 1122 |
-
<center> v0.
|
| 1123 |
chatbot = gr.Chatbot()
|
| 1124 |
with gr.Row():
|
| 1125 |
inputtext = gr.Textbox(
|
|
|
|
| 65 |
import asyncio
|
| 66 |
from playwright.async_api import async_playwright
|
| 67 |
|
| 68 |
+
|
| 69 |
+
from langchain.embeddings.huggingface import HuggingFaceEmbeddings
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
# os.environ['MPLCONFIGDIR'] = os.path.expanduser('/home/user/matplotlib_cache')
|
| 75 |
|
| 76 |
async def start_playwright(question: str):
|
| 77 |
pw = await async_playwright().start()
|
|
|
|
| 495 |
deployment_name=os.environ["deployment_name"],
|
| 496 |
temperature=0,
|
| 497 |
)
|
| 498 |
+
|
| 499 |
+
|
| 500 |
+
|
| 501 |
+
|
| 502 |
+
|
| 503 |
+
|
| 504 |
llm = chat
|
| 505 |
|
| 506 |
llm_math = LLMMathChain.from_llm(llm)
|
|
|
|
| 519 |
|
| 520 |
# tools = load_tools(["Vector Database Search","Wikipedia Search","Python REPL","llm-math"], llm=llm)
|
| 521 |
|
| 522 |
+
# Openai embedding
|
| 523 |
+
embeddings_openai = OpenAIEmbeddings(deployment="model_embedding", chunk_size=15)
|
| 524 |
+
|
| 525 |
+
# huggingface embedding model
|
| 526 |
+
embed_model_id = 'sentence-transformers/all-MiniLM-L6-v2'
|
| 527 |
+
|
| 528 |
+
# device = f'cuda:{cuda.current_device()}' if cuda.is_available() else 'cpu'
|
| 529 |
+
device = 'cpu'
|
| 530 |
+
embed_model = HuggingFaceEmbeddings(
|
| 531 |
+
model_name=embed_model_id,
|
| 532 |
+
model_kwargs={'device': device},
|
| 533 |
+
encode_kwargs={'device': device, 'batch_size': 32}
|
| 534 |
+
)
|
| 535 |
+
|
| 536 |
+
embeddings = embed_model
|
| 537 |
+
|
| 538 |
|
| 539 |
# embeddings = OpenAIEmbeddings(deployment="model_embedding_2", chunk_size=15)
|
| 540 |
|
|
|
|
| 1146 |
|
| 1147 |
with gr.Column() as main2:
|
| 1148 |
title = gr.Markdown("""# <center> STLA BABY - YOUR FRIENDLY GUIDE
|
| 1149 |
+
<center> v0.6: Powered by MECH Core Team - GPT4 REMOTE MODE"""),
|
| 1150 |
chatbot = gr.Chatbot()
|
| 1151 |
with gr.Row():
|
| 1152 |
inputtext = gr.Textbox(
|