KingNish commited on
Commit
52811e4
1 Parent(s): 8dbc926

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -1
app.py CHANGED
@@ -1,7 +1,32 @@
 
1
  import gradio as gr
 
 
 
 
 
 
2
 
3
- # Define the classification function
4
  def classify_task(prompt):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  # Here you would implement the logic to classify the prompt
6
  # For example, using if-elif-else statements or a machine learning model
7
  if 'generate text' in prompt.lower():
 
1
+ import re
2
  import gradio as gr
3
+ from huggingface_hub import InferenceClient
4
+
5
+ client = InferenceClient("mistralai/Mixtral-8x7B-Instruct-v0.1")
6
+
7
+ system_instructions = """<s> [INST] You will be provided with text, and your task is to classify task tasks are (text generation, image generation, pdf chat, image text to text, image classification, summarization, translation , tts) """
8
+
9
 
 
10
  def classify_task(prompt):
11
+ generate_kwargs = dict(
12
+ temperature=0.5,
13
+ max_new_tokens=1024,
14
+ top_p=0.95,
15
+ repetition_penalty=1.0,
16
+ do_sample=True,
17
+ seed=42,
18
+ )
19
+
20
+ formatted_prompt = system_instructions + prompt + "[/INST]"
21
+ stream = client.text_generation(
22
+ formatted_prompt, **generate_kwargs, stream=True, details=True, return_full_text=False)
23
+ output = ""
24
+
25
+ for response in stream:
26
+ output += response.token.text
27
+
28
+ # Define the classification function
29
+ def classify_task2(prompt):
30
  # Here you would implement the logic to classify the prompt
31
  # For example, using if-elif-else statements or a machine learning model
32
  if 'generate text' in prompt.lower():