Spaces:
Runtime error
Runtime error
url validateion and response updates
Browse files
app.py
CHANGED
@@ -16,7 +16,6 @@ def indexing(llm,path=None):
|
|
16 |
print("all done")
|
17 |
print(query_engine)
|
18 |
cl.user_session.set("engine", query_engine)
|
19 |
-
return query_engine
|
20 |
|
21 |
def qa(sp,engine,message):
|
22 |
message=message.content
|
@@ -28,24 +27,13 @@ def qa(sp,engine,message):
|
|
28 |
async def factory():
|
29 |
url = await cl.AskUserMessage(author="Beast",content="Enter url").send()
|
30 |
print(url)
|
31 |
-
index_ai = url['output'].find("ai")
|
32 |
-
url_ai = url['output'][:index_ai +
|
33 |
auth = await cl.AskUserMessage(author="Beast",content="Enter auth token").send()
|
34 |
print(auth)
|
35 |
model = 'deploy-llm'
|
36 |
llm = MonsterLLM(model=model,base_url=url_ai,monster_api_key=auth['output'],temperature=0.75, context_window=1024)
|
37 |
cl.user_session.set("llm", llm)
|
38 |
-
# files = None
|
39 |
-
# while files is None:
|
40 |
-
# files = await cl.AskFileMessage(author="Beast",
|
41 |
-
# content="Please upload a PDF file to begin!",
|
42 |
-
# accept=["application/pdf"],
|
43 |
-
# max_size_mb=20,
|
44 |
-
# timeout=180,
|
45 |
-
# ).send()
|
46 |
-
|
47 |
-
# pdf = files[0]
|
48 |
-
# print(pdf)
|
49 |
res = await cl.AskActionMessage(author="Beast",
|
50 |
content="Do you want to enter system prompt?",
|
51 |
actions=[
|
@@ -53,13 +41,20 @@ async def factory():
|
|
53 |
cl.Action(name="no", value="no", label="❌ No"),
|
54 |
],
|
55 |
).send()
|
56 |
-
query_engine = await cl.make_async(indexing)(llm)
|
57 |
if res and res.get("value") == "yes":
|
58 |
sp = await cl.AskUserMessage(author="Beast",content="Enter system prompt").send()
|
59 |
-
|
|
|
|
|
|
|
|
|
60 |
cl.user_session.set("sp", sp["output"])
|
61 |
else:
|
62 |
-
|
|
|
|
|
|
|
|
|
63 |
|
64 |
|
65 |
|
|
|
16 |
print("all done")
|
17 |
print(query_engine)
|
18 |
cl.user_session.set("engine", query_engine)
|
|
|
19 |
|
20 |
def qa(sp,engine,message):
|
21 |
message=message.content
|
|
|
27 |
async def factory():
|
28 |
url = await cl.AskUserMessage(author="Beast",content="Enter url").send()
|
29 |
print(url)
|
30 |
+
index_ai = url['output'].find(".monsterapi.ai")
|
31 |
+
url_ai = url['output'][:index_ai + len(".monsterapi.ai")]
|
32 |
auth = await cl.AskUserMessage(author="Beast",content="Enter auth token").send()
|
33 |
print(auth)
|
34 |
model = 'deploy-llm'
|
35 |
llm = MonsterLLM(model=model,base_url=url_ai,monster_api_key=auth['output'],temperature=0.75, context_window=1024)
|
36 |
cl.user_session.set("llm", llm)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
res = await cl.AskActionMessage(author="Beast",
|
38 |
content="Do you want to enter system prompt?",
|
39 |
actions=[
|
|
|
41 |
cl.Action(name="no", value="no", label="❌ No"),
|
42 |
],
|
43 |
).send()
|
|
|
44 |
if res and res.get("value") == "yes":
|
45 |
sp = await cl.AskUserMessage(author="Beast",content="Enter system prompt").send()
|
46 |
+
msg=cl.Message(author="Beast",content="Initiaing LLM....")
|
47 |
+
await msg.send()
|
48 |
+
await cl.make_async(indexing)(llm)
|
49 |
+
msg.content="Noted. Go ahead as your questions!!"
|
50 |
+
await msg.update()
|
51 |
cl.user_session.set("sp", sp["output"])
|
52 |
else:
|
53 |
+
msg=cl.Message(author="Beast",content="Initiaing LLM....")
|
54 |
+
await msg.send()
|
55 |
+
await cl.make_async(indexing)(llm)
|
56 |
+
msg.content="Okay, then you can start asking your questions!!"
|
57 |
+
await msg.update()
|
58 |
|
59 |
|
60 |
|