Update main.py
Browse files
main.py
CHANGED
@@ -22,6 +22,8 @@ from langchain_core.tracers.context import tracing_v2_enabled
|
|
22 |
|
23 |
import chainlit as cl
|
24 |
from chainlit.input_widget import TextInput, Select, Switch, Slider
|
|
|
|
|
25 |
|
26 |
from deep_translator import GoogleTranslator
|
27 |
|
@@ -45,10 +47,22 @@ def auth_callback(username: str, password: str):
|
|
45 |
def LLModel():
|
46 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HUGGINGFACEHUB_API_TOKEN']
|
47 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
48 |
-
|
49 |
repo_id=repo_id, max_new_tokens=5500, temperature=1.0, task="text2text-generation", streaming=True
|
50 |
)
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
def VectorDatabase(categorie):
|
54 |
if categorie != "year":
|
|
|
22 |
|
23 |
import chainlit as cl
|
24 |
from chainlit.input_widget import TextInput, Select, Switch, Slider
|
25 |
+
from chainlit.playground.config import add_llm_provider
|
26 |
+
from chainlit.playground.providers.langchain import LangchainGenericProvider
|
27 |
|
28 |
from deep_translator import GoogleTranslator
|
29 |
|
|
|
47 |
def LLModel():
|
48 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HUGGINGFACEHUB_API_TOKEN']
|
49 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
50 |
+
llm = HuggingFaceEndpoint(
|
51 |
repo_id=repo_id, max_new_tokens=5500, temperature=1.0, task="text2text-generation", streaming=True
|
52 |
)
|
53 |
+
add_llm_provider(
|
54 |
+
LangchainGenericProvider(
|
55 |
+
# It is important that the id of the provider matches the _llm_type
|
56 |
+
id=llm._llm_type,
|
57 |
+
# The name is not important. It will be displayed in the UI.
|
58 |
+
name="HuggingFaceHub",
|
59 |
+
# This should always be a Langchain llm instance (correctly configured)
|
60 |
+
llm=llm,
|
61 |
+
# If the LLM works with messages, set this to True
|
62 |
+
is_chat=True
|
63 |
+
)
|
64 |
+
)
|
65 |
+
return llm
|
66 |
|
67 |
def VectorDatabase(categorie):
|
68 |
if categorie != "year":
|