Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,20 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def chat_with_phi2(input_text):
|
4 |
+
# Encoding the input text
|
5 |
+
encoded_input = tokenizer(input_text, return_tensors='pt')
|
6 |
+
# Generating output using the fine-tuned model
|
7 |
+
output = model.generate(**encoded_input, max_length=50)
|
8 |
+
# Decoding the output tokens to a string
|
9 |
+
response = tokenizer.decode(output[0], skip_special_tokens=True)
|
10 |
+
return response
|
11 |
|
12 |
+
interface = gr.Interface(
|
13 |
+
fn=chat_with_phi2,
|
14 |
+
inputs=gr.inputs.Textbox(lines=2, placeholder="Ask something about W&L..."),
|
15 |
+
outputs="text",
|
16 |
+
title="W&L ChatGPT-like AI",
|
17 |
+
description="Ask any question about Washington and Lee University!"
|
18 |
+
)
|
19 |
+
|
20 |
+
interface.launch()
|