jophex commited on
Commit
b254c31
·
verified ·
1 Parent(s): 48fa3fe

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -5
app.py CHANGED
@@ -1,12 +1,14 @@
1
- import gradio as gr
2
 
3
 
4
 
5
- gradio_app = gr.Interface(
6
- title="Advertisment companion",
7
- )
 
 
8
 
9
- gr.load("models/microsoft/Phi-3.5-mini-instruct").launch(share=True)
10
 
11
 
12
 
@@ -51,3 +53,32 @@ gr.load("models/microsoft/Phi-3.5-mini-instruct").launch(share=True)
51
 
52
  # # Launch the Gradio app with sharing enabled
53
  # interface.launch(share=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import gradio as gr
2
 
3
 
4
 
5
+ # gradio_app = gr.Interface(
6
+ # inputs="text",
7
+ # outputs="text",
8
+ # title="Advertisment companion",
9
+ # )
10
 
11
+ # gr.load("models/microsoft/Phi-3.5-mini-instruct").launch(share=True)
12
 
13
 
14
 
 
53
 
54
  # # Launch the Gradio app with sharing enabled
55
  # interface.launch(share=True)
56
+
57
+
58
+ import gradio as gr
59
+ from transformers import pipeline
60
+
61
+ # Load the model pipeline for text generation
62
+ generator = pipeline("text-generation", model="microsoft/Phi-3.5-mini-instruct", use_auth_token=True)
63
+
64
+ # Define the role prompt for advertisement assistance
65
+ role_prompt = "You are an advertisement assistant. Respond professionally and helpfully to advertising-related questions.\n\n"
66
+
67
+ # Function to generate responses
68
+ def generate_response(user_input):
69
+ input_text = role_prompt + user_input
70
+ response = generator(input_text, max_new_tokens=50, temperature=0.7, top_p=0.9)
71
+ return response[0]["generated_text"]
72
+
73
+ # Set up Gradio interface
74
+ interface = gr.Interface(
75
+ fn=generate_response,
76
+ inputs="text",
77
+ outputs="text",
78
+ title="Advertisement Assistant Chatbot",
79
+ description="Ask me anything related to advertising. I'm here to help!"
80
+ )
81
+
82
+ # Launch the Gradio app with sharing enabled
83
+ interface.launch(share=True)
84
+