mayar-waleed commited on
Commit
4531117
·
1 Parent(s): 98e532c

Add application file

Browse files
Files changed (1) hide show
  1. app.py +5 -30
app.py CHANGED
@@ -1,32 +1,7 @@
1
- import gradio as gr
2
 
3
- from app.deps import get_chain
4
 
5
- def chat_fn(message, history):
6
- """
7
- history comes as: [(user_msg, bot_msg), ...]
8
- We'll convert it to your chain's expected format:
9
- [{"role":"user","content":...}, {"role":"assistant","content":...}, ...]
10
- """
11
- history_dicts = []
12
- for u, a in history:
13
- if u:
14
- history_dicts.append({"role": "user", "content": u})
15
- if a:
16
- history_dicts.append({"role": "assistant", "content": a})
17
-
18
- chain = get_chain(conversation_history=history_dicts)
19
-
20
- # Your chain.invoke is sync
21
- result = chain.invoke(message)
22
- answer = result.get("answer", "") if isinstance(result, dict) else str(result)
23
- return answer
24
-
25
- demo = gr.ChatInterface(
26
- fn=chat_fn,
27
- title="Legal RAG Chatbot",
28
- description="Ask questions and get answers with retrieved context."
29
- )
30
-
31
- if __name__ == "__main__":
32
- demo.launch()
 
1
+ from fastapi import FastAPI
2
 
3
+ app = FastAPI()
4
 
5
+ @app.get("/")
6
+ def greet_json():
7
+ return {"Hello": "World!"}