MatteoScript commited on
Commit
48711f9
·
verified ·
1 Parent(s): 49dd983

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +23 -2
main.py CHANGED
@@ -28,6 +28,9 @@ app.add_middleware(
28
 
29
  class InputData(BaseModel):
30
  input: str
 
 
 
31
  temperature: float = 0.7
32
  max_new_tokens: int = 30000
33
  top_p: float = 0.95
@@ -46,17 +49,35 @@ class PostSpazio(BaseModel):
46
  nomeSpazio: str
47
  input: str = ''
48
  api_name: str = "/chat"
49
-
50
 
51
  #--------------------------------------------------- Generazione TESTO ------------------------------------------------------
52
  @app.post("/Genera")
53
  def read_root(request: Request, input_data: InputData):
54
- input_text = input_data.input
55
  temperature = input_data.temperature
56
  max_new_tokens = input_data.max_new_tokens
57
  top_p = input_data.top_p
58
  repetition_penalty = input_data.repetition_penalty
59
  history = []
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  generated_response = generate(input_text, history, temperature, max_new_tokens, top_p, repetition_penalty)
61
  return {"response": generated_response}
62
 
 
28
 
29
  class InputData(BaseModel):
30
  input: str
31
+ systemRole: str = ''
32
+ systemStyle: str = ''
33
+ instruction: str = ''
34
  temperature: float = 0.7
35
  max_new_tokens: int = 30000
36
  top_p: float = 0.95
 
49
  nomeSpazio: str
50
  input: str = ''
51
  api_name: str = "/chat"
 
52
 
53
  #--------------------------------------------------- Generazione TESTO ------------------------------------------------------
54
  @app.post("/Genera")
55
  def read_root(request: Request, input_data: InputData):
 
56
  temperature = input_data.temperature
57
  max_new_tokens = input_data.max_new_tokens
58
  top_p = input_data.top_p
59
  repetition_penalty = input_data.repetition_penalty
60
  history = []
61
+ input_text = = f'''
62
+ {{
63
+ "input": {{
64
+ "role": "system",
65
+ "content": "{input_data.systemRole}",
66
+ "style": "{input_data.systemStyle}",
67
+
68
+ }},
69
+ "messages": [
70
+ {{
71
+ "role": "instructions",
72
+ "content": {input_data.instruction}
73
+ }},
74
+ {{
75
+ "role": "user",
76
+ "content": "{input_data.input}"
77
+ }}
78
+ ]
79
+ }}
80
+ '''
81
  generated_response = generate(input_text, history, temperature, max_new_tokens, top_p, repetition_penalty)
82
  return {"response": generated_response}
83