Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -11,7 +11,7 @@ from data_process import *
|
|
11 |
from langchain.tools.base import StructuredTool
|
12 |
from langchain.agents import initialize_agent
|
13 |
from qa_txt import llm
|
14 |
-
|
15 |
import pathlib
|
16 |
import gradio as gr
|
17 |
import threading, time
|
@@ -108,21 +108,21 @@ fetch_data = StructuredTool.from_function(
|
|
108 |
# """,
|
109 |
# )
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
|
127 |
|
128 |
|
@@ -152,7 +152,7 @@ tools_add = [
|
|
152 |
qa_faq,
|
153 |
fetch_data,
|
154 |
analyze_data,
|
155 |
-
|
156 |
]
|
157 |
|
158 |
agent = create_react_agent(llm=llm, tools=tools_add, prompt=prompt)
|
|
|
11 |
from langchain.tools.base import StructuredTool
|
12 |
from langchain.agents import initialize_agent
|
13 |
from qa_txt import llm
|
14 |
+
from trans import trans
|
15 |
import pathlib
|
16 |
import gradio as gr
|
17 |
import threading, time
|
|
|
108 |
# """,
|
109 |
# )
|
110 |
|
111 |
+
def translate(query: str) -> str:
|
112 |
+
translated = trans.invoke({"input": query})['text']
|
113 |
+
return translated
|
114 |
|
115 |
+
translate_text = StructuredTool.from_function(
|
116 |
+
func=translate,
|
117 |
+
description= """
|
118 |
+
Translate from any language to french. Don't use it if the text is already in french
|
119 |
|
120 |
+
Parameters :
|
121 |
+
- query (string) : the same input as the user input no more no less.
|
122 |
+
Returns :
|
123 |
+
- string : isolate just the translated text in french with no other useless words.
|
124 |
+
""",
|
125 |
+
)
|
126 |
|
127 |
|
128 |
|
|
|
152 |
qa_faq,
|
153 |
fetch_data,
|
154 |
analyze_data,
|
155 |
+
translate_text,
|
156 |
]
|
157 |
|
158 |
agent = create_react_agent(llm=llm, tools=tools_add, prompt=prompt)
|