TRaw commited on
Commit
056fad8
·
1 Parent(s): 715716a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -21
app.py CHANGED
@@ -1,23 +1,29 @@
1
- import openai
 
2
  import gradio as gr
3
 
4
- system_content = "You are a travel agent. Be descriptive and helpful."
5
- user_content = "Tell me about San Francisco"
6
-
7
- client = openai.OpenAI(
8
- api_key="f722a9f6e3afd6b9999e6aee02aeac9e751ea3a67b124c3667ab50c85c7fa99e",
9
- base_url="https://api.together.xyz/v1",
10
- )
11
-
12
- def chat_completion: client.chat.completions.create(
13
- model="mistralai/Mixtral-8x7B-Instruct-v0.1",
14
- messages=[
15
- {"role": "system", "content": system_content},
16
- {"role": "user", "content": user_content},
17
- ],
18
- temperature=0.7,
19
- max_tokens=1024,
20
- )
21
- response = chat_completion.choices[0].message.content
22
-
23
- gr.ChatInterface(predict).queue().launch()
 
 
 
 
 
 
1
+ import lightning as L
2
+ from lightning.app.components import ServeGradio
3
  import gradio as gr
4
 
5
+ class LitGradio(ServeGradio):
6
+
7
+ inputs = gr.inputs.Textbox(default='lightning', label='name input')
8
+ outputs = gr.outputs.Textbox(label='output')
9
+ examples = [["hello lightning"]]
10
+
11
+ def predict(self, input_text):
12
+ return self.model(input_text)
13
+
14
+ def build_model(self):
15
+ fake_model = lambda x: f"hello {x}"
16
+ return fake_model
17
+
18
+ class RootFlow(L.LightningFlow):
19
+ def __init__(self):
20
+ super().__init__()
21
+ self.lit_gradio = LitGradio()
22
+
23
+ def run(self):
24
+ self.lit_gradio.run()
25
+
26
+ def configure_layout(self):
27
+ return [{"name": "home", "content": self.lit_gradio}]
28
+
29
+ app = L.LightningApp(RootFlow())