Update main.py
Browse files
main.py
CHANGED
|
@@ -47,15 +47,18 @@ async def chat_profile():
|
|
| 47 |
cl.ChatProfile(name="Imagestream",markdown_description="Requêter sur un ensemble d'images",icon="./public/logo-ofipe.jpg",),
|
| 48 |
]
|
| 49 |
|
| 50 |
-
@cl.
|
| 51 |
-
async def
|
| 52 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HUGGINGFACEHUB_API_TOKEN']
|
| 53 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 54 |
|
| 55 |
llm = HuggingFaceEndpoint(
|
| 56 |
repo_id=repo_id, max_new_tokens=8000, temperature=1.0, task="text2text-generation", streaming=True
|
| 57 |
)
|
|
|
|
| 58 |
|
|
|
|
|
|
|
| 59 |
await cl.Message(f"> REVIEWSTREAM").send()
|
| 60 |
await cl.Message(f"Nous avons le plaisir de vous accueillir dans l'application de recherche et d'analyse des publications.").send()
|
| 61 |
listPrompts_name = f"Liste des revues de recherche"
|
|
@@ -88,6 +91,7 @@ async def on_chat_start():
|
|
| 88 |
{question} [/INST] </s>
|
| 89 |
"""
|
| 90 |
prompt = PromptTemplate(template=template, input_variables=["question","context"])
|
|
|
|
| 91 |
chain = (
|
| 92 |
RunnablePassthrough.assign(
|
| 93 |
history=RunnableLambda(memory.load_memory_variables) | itemgetter("history")
|
|
|
|
| 47 |
cl.ChatProfile(name="Imagestream",markdown_description="Requêter sur un ensemble d'images",icon="./public/logo-ofipe.jpg",),
|
| 48 |
]
|
| 49 |
|
| 50 |
+
@cl.step(type="llm")
|
| 51 |
+
async def IA():
|
| 52 |
os.environ['HUGGINGFACEHUB_API_TOKEN'] = os.environ['HUGGINGFACEHUB_API_TOKEN']
|
| 53 |
repo_id = "mistralai/Mixtral-8x7B-Instruct-v0.1"
|
| 54 |
|
| 55 |
llm = HuggingFaceEndpoint(
|
| 56 |
repo_id=repo_id, max_new_tokens=8000, temperature=1.0, task="text2text-generation", streaming=True
|
| 57 |
)
|
| 58 |
+
return llm
|
| 59 |
|
| 60 |
+
@cl.on_chat_start
|
| 61 |
+
async def on_chat_start():
|
| 62 |
await cl.Message(f"> REVIEWSTREAM").send()
|
| 63 |
await cl.Message(f"Nous avons le plaisir de vous accueillir dans l'application de recherche et d'analyse des publications.").send()
|
| 64 |
listPrompts_name = f"Liste des revues de recherche"
|
|
|
|
| 91 |
{question} [/INST] </s>
|
| 92 |
"""
|
| 93 |
prompt = PromptTemplate(template=template, input_variables=["question","context"])
|
| 94 |
+
llm = await IA()
|
| 95 |
chain = (
|
| 96 |
RunnablePassthrough.assign(
|
| 97 |
history=RunnableLambda(memory.load_memory_variables) | itemgetter("history")
|