Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,19 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import
|
3 |
|
4 |
-
# Load your text generation model from Hugging Face
|
5 |
-
|
6 |
-
|
|
|
7 |
|
8 |
def generate_response(input_prompt):
|
|
|
|
|
|
|
9 |
# Generate response
|
10 |
-
|
|
|
|
|
11 |
return response
|
12 |
|
13 |
# Create Gradio interface
|
@@ -19,6 +25,6 @@ gr.Interface(
|
|
19 |
inputs=input_prompt,
|
20 |
outputs=output_text,
|
21 |
title="OmniCode",
|
22 |
-
description="Multi
|
23 |
theme="compact"
|
24 |
).launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import AutoModelForCausalLM, AutoTokenizer
|
3 |
|
4 |
+
# Load your text generation model from Hugging Face using its identifier
|
5 |
+
model_identifier = "your-model-name-on-hugging-face"
|
6 |
+
model = AutoModelForCausalLM.from_pretrained(model_identifier)
|
7 |
+
tokenizer = AutoTokenizer.from_pretrained(model_identifier)
|
8 |
|
9 |
def generate_response(input_prompt):
|
10 |
+
# Tokenize input prompt
|
11 |
+
input_ids = tokenizer.encode(input_prompt, return_tensors="pt", max_length=512, truncation=True)
|
12 |
+
|
13 |
# Generate response
|
14 |
+
output_ids = model.generate(input_ids, max_length=100, num_return_sequences=1)
|
15 |
+
response = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
16 |
+
|
17 |
return response
|
18 |
|
19 |
# Create Gradio interface
|
|
|
25 |
inputs=input_prompt,
|
26 |
outputs=output_text,
|
27 |
title="OmniCode",
|
28 |
+
description="Multi programming coding assistant",
|
29 |
theme="compact"
|
30 |
).launch()
|