Spaces:
Runtime error
Runtime error
File size: 4,460 Bytes
443d813 bb3d59f 443d813 c4af7b2 5e3b3e8 83c4030 443d813 5e3b3e8 443d813 54f0e1b 443d813 54f0e1b 443d813 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | import openai
import gradio as gr
import os
API_TOKEN = os.environ["API_TOKEN"]
def chatbot(input,systemInstructions):
openai.api_key = API_TOKEN
if input:
messages = [
{"role": "system", "content": systemInstructions},
]
messages.append({"role": "user", "content": input})
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=messages,
temperature=0.8,
top_p=0.3,
n=1,
max_tokens = 1024,
presence_penalty = 0.5,
frequency_penalty = 0.5,
#logit_bias
)
reply = chat.choices[0].message.content
messages.append({"role": "assistant", "content": reply})
return reply
def emojobot(input):
generatedKnowledgeCorpus = """
MODEL RAM SS
Motor type DC Brushless
Motor power 750W
Rated Voltage 48 V
Maximum speed 20 MPH
Battery range 30Miles
Battery charging time 4 - 6hours
Battery type Lithium-Ion
Battery capacity 48V/10.4Ah
Dimensions (inch) 67L x 24 W x 45 H
Dimensions folded 39L x 18 W x 26H
Frame Aluminum-foldable
Max. user weight 230 lbs
Vehicle weight 55 lbs (with battery)
Transmission type Shimano 7-Speed
Front brake type Tektro-Disc
Rear brake type Tektro-Disc
Tire size 20" x 4"
MODEL LYNX PRO 750
Motor type DC Brushless
Motor power 750W
Rated Voltage 48 V
Maximum speed 20 MPH
Battery range 30 Miles
Battery charging time 4 - 6hours
Battery type Lithium-Ion
Battery capacity 48V/10.4Ah
Dimensions (inch) 67L x 24 W x 45 H
Dimensions folded 39L x 18 W x 26H
Frame Aluminum-foldable
Max. user weight 230 lbs
Vehicle weight 55 lbs (with battery)
Transmission type Shimano Altus 7-Speed
Front brake type Tektro-Disc
Rear brake type Tektro-Disc
Tire size 20" x 4"
MODEL WILDCAT PRO 750
Motor type DC Brushless
Motor power 750W
Rated Voltage 48V
Maximum speed 20 MPH
Battery range 30 Miles
Battery charging time 4-6 hours
Battery type Lithium-Ion
Battery capacity 48V/10.4 Ah
Dimensions (inch) 78L x 25W x 43H
Frame Aluminum-Rigid
Max.user weight 330 lbs
Transmission type Shimano 7-Speed
Front brake type hydraulic brake
Rear brake type hydraulic brake
Tire size 26" x 4"
MODEL WILDCAT
Motor type DC Brushless
Motor power 500W
Rated Voltage 48V
Maximum speed 20 MPH
Battery range 30 Miles
Battery charging time 4-6 hours
Battery type Lithium-Ion
Battery capacity 48V/10.4 Ah
Dimensions (inch) 78L x 25W x 43H
Frame Aluminum-Rigid
Max.user weight 330 lbs
Transmission type Shimano 7-Speed
Front brake type hydraulic brake
Rear brake type hydraulic brake
Tire size 26" x 4"
MODEL RAM SS
Motor type DC Brushless
Motor power 750W
Rated Voltage 48 V
Maximum speed 20 MPH
Battery range 30Miles
Battery charging time 4 - 6hours
Battery type Lithium-Ion
Battery capacity 48V/10.4Ah
Dimensions (inch) 67L x 24 W x 45 H
Dimensions folded 39L x 18 W x 26H
Frame Aluminum-foldable
Max. user weight 230 lbs
Vehicle weight 55 lbs (with battery)
Transmission type Shimano 7-Speed
Front brake type Tektro-Disc
Rear brake type Tektro-Disc
Tire size 20" x 4"
MODEL LYNX PRO SPORT
Motor type DC Brushless
Motor power 500W
Rated Voltage 48 V
Maximum speed 20 MPH
Battery range 30Miles
Battery charging time 4 - 6hours
Battery type Lithium-Ion
Battery capacity 48V/10.4Ah
Dimensions (inch) 67L x 24 W x 45 H
Dimensions folded 39L x 18 W x 26H
Frame Aluminum-foldable
Max. user weight 230 lbs
Vehicle weight 55 lbs (with battery)
Transmission type Shimano 7-Speed
Front brake type Tektro-Disc
Rear brake type Tektro-Disc
Tire size 20" x 4"
"""
generatedKnowledgeCorpus = generatedKnowledgeCorpus.replace("\n","")
systemInstructions = "You are a customer who purchased emojo bike and will write excellent customer reviews. Use the following text and write. '\
"
systemInstructions = systemInstructions + '\n\n' + generatedKnowledgeCorpus
response = chatbot(input, systemInstructions)
return response
inputs = gr.inputs.Textbox(label="Bike Series for Review")
outputs = gr.outputs.Textbox(label="Customer Review")
with gr.Blocks() as demo:
gr.Markdown(
"""
# Emojo Service| In Development
"""
)
responseBox = gr.Interface(fn=emojobot, inputs=[inputs], outputs=outputs, allow_flagging='never')
if __name__ == "__main__":
demo.launch() |