spg commited on
Commit
16314be
1 Parent(s): a34cbfb

Upload 3 files

Browse files
Files changed (3) hide show
  1. Stok +50 -0
  2. app.py +89 -177
  3. content.txt +1 -0
Stok ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ import xml.etree.ElementTree as ET
3
+ from transformers import pipeline
4
+
5
+ # Hugging Face pipeline'ını yükle
6
+ nlp = pipeline('text-generation', model='EleutherAI/gpt-neo-2.7B')
7
+
8
+ # API url'si
9
+ url = 'https://bizimhesap.com/api/product/getproductsasxml?apikey=6F4BAF303FA240608A39653824B6C495'
10
+
11
+ # Verileri al
12
+ response = requests.get(url)
13
+ xml_data = response.content
14
+
15
+ # XML verilerini ayrıştır
16
+ root = ET.fromstring(xml_data)
17
+ products = root.findall('urunler/urun')
18
+
19
+ # Chatbot'a girdi al
20
+ input_text = input("Merhaba, ne yapabilirim? ")
21
+
22
+ # Girdiye göre yanıt üret
23
+ if 'stok' in input_text and ('durum' in input_text or 'seviye' in input_text):
24
+ # Eğer kullanıcı stok durumunu sorduysa
25
+ for product in products:
26
+ if product.find('urun_ad').text.lower() in input_text.lower():
27
+ stok = int(product.find('stok').text)
28
+ if stok > 0:
29
+ response_text = f"{product.find('urun_ad').text} ürününden {stok} adet mevcut."
30
+ else:
31
+ response_text = f"{product.find('urun_ad').text} ürünü stoklarda yok."
32
+ break
33
+ else:
34
+ response_text = "Aradığınız ürün stoklarda yok."
35
+ elif 'fiyat' in input_text:
36
+ # Eğer kullanıcı fiyat bilgisi istiyorsa
37
+ for product in products:
38
+ if product.find('urun_ad').text.lower() in input_text.lower():
39
+ price = float(product.find('satis_fiyat').text)
40
+ response_text = f"{product.find('urun_ad').text} ürününün fiyatı {price:.2f} TL."
41
+ break
42
+ else:
43
+ response_text = "Aradığınız ürün fiyatı hakkında bilgi verilemedi."
44
+ else:
45
+ # Girdiye göre otomatik bir yanıt üret
46
+ generated_text = nlp(input_text, max_length=50, do_sample=True, temperature=0.7)
47
+ response_text = generated_text[0]['generated_text'].strip()
48
+
49
+ # Yanıtı yazdır
50
+ print(response_text)
app.py CHANGED
@@ -1,194 +1,106 @@
1
  import gradio as gr
2
- import os
3
- import sys
4
  import json
5
  import requests
6
 
7
- MODEL = "gpt-3.5-turbo"
8
- API_URL = os.getenv("API_URL")
9
- DISABLED = os.getenv("DISABLED") == 'True'
10
- OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
11
- NUM_THREADS = 1
12
-
13
- print (NUM_THREADS)
14
-
15
- def exception_handler(exception_type, exception, traceback):
16
- print("%s: %s" % (exception_type.__name__, exception))
17
- sys.excepthook = exception_handler
18
- sys.tracebacklimit = 0
19
-
20
- #https://github.com/gradio-app/gradio/issues/3531#issuecomment-1484029099
21
- def parse_codeblock(text):
22
- lines = text.split("\n")
23
- for i, line in enumerate(lines):
24
- if "```" in line:
25
- if line != "```":
26
- lines[i] = f'<pre><code class="{lines[i][3:]}">'
27
- else:
28
- lines[i] = '</code></pre>'
29
- else:
30
- if i > 0:
31
- lines[i] = "<br/>" + line.replace("<", "&lt;").replace(">", "&gt;")
32
- return "".join(lines)
33
-
34
- def predict(inputs, top_p, temperature, chat_counter, chatbot, history, request:gr.Request):
35
- payload = {
36
- "model": MODEL,
37
- "messages": [{"role": "user", "content": f"{inputs}"}],
38
- "temperature" : 1.0,
39
- "top_p":1.0,
40
- "n" : 1,
41
- "stream": True,
42
- "presence_penalty":0,
43
- "frequency_penalty":0,
44
- }
45
 
 
46
  headers = {
47
- "Content-Type": "application/json",
48
- "Authorization": f"Bearer {OPENAI_API_KEY}",
49
- "Headers": f"{request.kwargs['headers']}"
50
  }
51
-
52
- # print(f"chat_counter - {chat_counter}")
53
- if chat_counter != 0 :
54
- messages = []
55
- for i, data in enumerate(history):
56
- if i % 2 == 0:
57
- role = 'user'
58
- else:
59
- role = 'assistant'
60
- message = {}
61
- message["role"] = role
62
- message["content"] = data
63
- messages.append(message)
64
-
65
- message = {}
66
- message["role"] = "user"
67
- message["content"] = inputs
68
- messages.append(message)
69
- payload = {
70
- "model": MODEL,
71
- "messages": messages,
72
- "temperature" : temperature,
73
- "top_p": top_p,
74
- "n" : 1,
75
- "stream": True,
76
- "presence_penalty":0,
77
- "frequency_penalty":0,
78
- }
79
-
80
- chat_counter += 1
 
 
 
 
81
 
82
  history.append(inputs)
 
 
 
 
83
  token_counter = 0
84
  partial_words = ""
85
- counter = 0
86
 
87
- try:
88
- # make a POST request to the API endpoint using the requests.post method, passing in stream=True
89
- response = requests.post(API_URL, headers=headers, json=payload, stream=True)
90
- response_code = f"{response}"
91
- #if response_code.strip() != "<Response [200]>":
92
- # #print(f"response code - {response}")
93
- # raise Exception(f"Sorry, hitting rate limit. Please try again later. {response}")
 
 
94
 
95
- for chunk in response.iter_lines():
96
- #Skipping first chunk
97
- if counter == 0:
98
- counter += 1
99
- continue
100
- #counter+=1
101
- # check whether each line is non-empty
102
- if chunk.decode() :
103
- chunk = chunk.decode()
104
- # decode each line as response data is in bytes
105
- if len(chunk) > 12 and "content" in json.loads(chunk[6:])['choices'][0]['delta']:
106
- partial_words = partial_words + json.loads(chunk[6:])['choices'][0]["delta"]["content"]
107
- if token_counter == 0:
108
- history.append(" " + partial_words)
109
- else:
110
- history[-1] = partial_words
111
- token_counter += 1
112
- yield [(parse_codeblock(history[i]), parse_codeblock(history[i + 1])) for i in range(0, len(history) - 1, 2) ], history, chat_counter, response, gr.update(interactive=False), gr.update(interactive=False) # resembles {chatbot: chat, state: history}
113
- except Exception as e:
114
- print (f'error found: {e}')
115
- yield [(parse_codeblock(history[i]), parse_codeblock(history[i + 1])) for i in range(0, len(history) - 1, 2) ], history, chat_counter, response, gr.update(interactive=True), gr.update(interactive=True)
116
- print(json.dumps({"chat_counter": chat_counter, "payload": payload, "partial_words": partial_words, "token_counter": token_counter, "counter": counter}))
117
-
118
-
119
  def reset_textbox():
120
- return gr.update(value='', interactive=False), gr.update(interactive=False)
121
-
122
- title = """<h1 align="center">GPT-3.5 Chatbot</h1>"""
123
- if DISABLED:
124
- title = """<h1 align="center" style="color:red">This app has reached OpenAI's usage limit. We are currently requesting an increase in our quota. Please check back in a few days.</h1>"""
125
- description = """Language models can be conditioned to act like dialogue agents through a conversational prompt that typically takes the form:
126
- ```
127
- User: <utterance>
128
- Assistant: <utterance>
129
- User: <utterance>
130
- Assistant: <utterance>
131
- ...
132
- ```
133
- In this app, you can explore the outputs of a gpt-3.5 LLM.
134
- """
135
-
136
- theme = gr.themes.Default(primary_hue="green")
137
-
138
- with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;}
139
- #chatbot {height: 520px; overflow: auto;}""",
140
- theme=theme) as demo:
141
- gr.HTML(title)
142
- gr.HTML("""<h3 align="center">This app provides you full access to GPT-3.5 (4096 token limit). You don't need any OPENAI API key.</h1>""")
143
- #gr.HTML('''<center><a href="https://huggingface.co/spaces/yuntian-deng/ChatGPT?duplicate=true"><img src="https://bit.ly/3gLdBN6" alt="Duplicate Space"></a>Duplicate the Space and run securely with your OpenAI API Key</center>''')
144
- with gr.Column(elem_id = "col_container", visible=False) as main_block:
145
- #API Key is provided by OpenAI
146
- #openai_api_key = gr.Textbox(type='password', label="Enter only your OpenAI API key here")
147
- chatbot = gr.Chatbot(elem_id='chatbot') #c
148
- inputs = gr.Textbox(placeholder= "Hi there!", label= "Type an input and press Enter") #t
149
- state = gr.State([]) #s
150
- with gr.Row():
151
- with gr.Column(scale=7):
152
- b1 = gr.Button(visible=not DISABLED).style(full_width=True)
153
- with gr.Column(scale=3):
154
- server_status_code = gr.Textbox(label="Status code from OpenAI server", )
155
-
156
- #inputs, top_p, temperature, top_k, repetition_penalty
157
- with gr.Accordion("Parameters", open=False):
158
- top_p = gr.Slider( minimum=-0, maximum=1.0, value=1.0, step=0.05, interactive=True, label="Top-p (nucleus sampling)",)
159
- temperature = gr.Slider( minimum=-0, maximum=5.0, value=1.0, step=0.1, interactive=True, label="Temperature",)
160
- #top_k = gr.Slider( minimum=1, maximum=50, value=4, step=1, interactive=True, label="Top-k",)
161
- #repetition_penalty = gr.Slider( minimum=0.1, maximum=3.0, value=1.03, step=0.01, interactive=True, label="Repetition Penalty", )
162
  chat_counter = gr.Number(value=0, visible=False, precision=0)
163
-
164
- with gr.Column(elem_id = "user_consent_container") as user_consent_block:
165
- # Get user consent
166
- accept_checkbox = gr.Checkbox(visible=False)
167
- js = "(x) => confirm('By clicking \"OK\", I agree that my data may be published or shared.')"
168
- with gr.Accordion("User Consent for Data Collection, Use, and Sharing", open=True):
169
- gr.HTML("""
170
- <div>
171
- <p>By using our app, which is powered by OpenAI's API, you acknowledge and agree to the following terms regarding the data you provide:</p>
172
- <ol>
173
- <li><strong>Collection:</strong> We may collect information, including the inputs you type into our app, the outputs generated by OpenAI's API, and certain technical details about your device and connection (such as browser type, operating system, and IP address) provided by your device's request headers.</li>
174
- <li><strong>Use:</strong> We may use the collected data for research purposes, to improve our services, and to develop new products or services, including commercial applications, and for security purposes, such as protecting against unauthorized access and attacks.</li>
175
- <li><strong>Sharing and Publication:</strong> Your data, including the technical details collected from your device's request headers, may be published, shared with third parties, or used for analysis and reporting purposes.</li>
176
- <li><strong>Data Retention:</strong> We may retain your data, including the technical details collected from your device's request headers, for as long as necessary.</li>
177
- </ol>
178
- <p>By continuing to use our app, you provide your explicit consent to the collection, use, and potential sharing of your data as described above. If you do not agree with our data collection, use, and sharing practices, please do not use our app.</p>
179
- </div>
180
- """)
181
- accept_button = gr.Button("I Agree")
182
-
183
- def enable_inputs():
184
- return user_consent_block.update(visible=False), main_block.update(visible=True)
185
 
186
- accept_button.click(None, None, accept_checkbox, _js=js, queue=False)
187
- accept_checkbox.change(fn=enable_inputs, inputs=[], outputs=[user_consent_block, main_block], queue=False)
 
 
188
 
189
- inputs.submit(reset_textbox, [], [inputs, b1], queue=False)
190
- inputs.submit(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
191
- b1.click(reset_textbox, [], [inputs, b1], queue=False)
192
- b1.click(predict, [inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter, server_status_code, inputs, b1],) #openai_api_key
193
-
194
- demo.queue(max_size=20, concurrency_count=NUM_THREADS, api_open=False).launch(share=False)
 
1
  import gradio as gr
2
+ import os
 
3
  import json
4
  import requests
5
 
6
+
7
+ API_URL = "https://api.openai.com/v1/chat/completions" #os.getenv("API_URL") + "/generate_stream"
8
+ OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ def predict(system_msg, inputs, top_p, temperature, chat_counter, chatbot=[], history=[]):
11
  headers = {
12
+ "Content-Type": "application/json",
13
+ "Authorization": f"Bearer {OPENAI_API_KEY}"
 
14
  }
15
+ print(f"system message is ^^ {system_msg}")
16
+ initial_message = [{"role": "user", "content": f"{inputs}"},]
17
+ multi_turn_message = [{"role": "system", "content": "Sen bir AI Trek marka bisiklet uzmanı, bilir kişisi ve asistanısın. Trek bisiklet dışında hiç bir konuda cevap vermeyeceksin. Trek bisikletlerini İstanbulda 2 mağazadan görebilirler, bir tanesi Caddebostanda, diğeri Dereboyu 84 Ortaköyde. Ortaköy mağazası Saat 10.00 da açılıp, 19.00 da kapanıyor. Telefon numarası 0212 2271015. caddebostan mağazamızın adresi: Prof. Dr. Hulusi Behçet 18 Caddebostan, Kadıköy. Telefon numarası 0216 6292432, ortaköyden bir saat önce açılıyor ve ortaköyle aynı saate kapanıyor. Ortaköy mağazası Pazar günleri kapalıdır. Ancak Caddebostan mağazamız haftanın 7 günü açıktır. Caddebostan mağazası her gün 09.00 da açılır ve 19.00 kapanır. sadece Pazar günleri 10.00 da açılır ve 17.00 de kapanır. Caddebostan mağazamızda haftanın 1 günü Bike-Fit yapılmaktadır. Retul firmasının bikefit makinesini kullanıyoruz. Salı günleri bike-fit yapabiliyoruz. Yapan kişi Emre Yavuz. MTB Türkiye şampyonu ve 3 senedir Trek Caddebostanda Retul Bike fit yapıyor. Bike fit için rezervasyon yapılması gerekir. Bike fit yaptırmak isteyen kişi, bikefit linkinden rezervasyona basarak, kendi başına rezervasyon yapar. 2012 yılından beri Retul Bike Fit hizmeti veriyoruz."},
18
+ {"role": "system", "content": "Trek Türkiye canlı destek hattına hoş geldiniz, demeyeceksin. Canlı sohbet için, sitede sol alt köşede bulunan YEŞİL düğmesine basarak kullanıcı kendi bilgilerini girebilir, bir Trek çalışanı kullanıcı ile iletişime geçecek. Trek Türkiye için web adresimiz: https://www.alatin.com.tr "},
19
+ {"role": "system", "content": "Bike fit ücreti 1400 TL. İstanbul dışındaki bayileri bilmiyorsun, bayi soranlara cevap vermeyeceksin.. Tüm bayi detayları için https://www.alatin.com.tr/sayfa/bayilerimiz/ linkinine baksınlar. Bikefit işlem süresi yaklaşık 60 - 90 dakikadır."},
20
+ {"role": "system", "content": "Trek bisiklet fiyatları ile ilgili bilgi vermeyeceksin. Hiç bir fiyatı bilmiyorsun. Fiyat soranlara güncel fiyatlar için sitemizi ziyaret etmelerini söyle. Boy bilgisini biliyorsan, uygun kadro boyunu öner. Kadro boyu sorularinda hangi bisiklet tipi icin soruldugunu ögren. Yol bisikleti ise CM cinsinden kadro boyu öner. dag bisikleti, kadro boyu soruluyorsa S,M,ML,L,XL cinsinden cevapla. Şehir bisikletlerinde 4 boy var; S,M,L,XL. FX, DS, VERVE sehir bisiketleridir. Marlin, Roscoe, Procaliber, Supercaliber, Fuel_EX dag bisikletidir."},
21
+ {"role": "system", "content": "Başka marka bisikletleri önermeyeceksin. Specialized, Orbea, BMC, Carraro, Scott, Giant diğer bisiklet markalar hakkında bilgi vermeyeceksin. Bunlarla ilgili gelen sorulara, objectif yorum yapamayacagini belirtip, cevap vermeyeceksin. Trek bu sayilan markalardan daha farkli bir teknoloji kullaniyor, bu teklonoji bisikletin saglamligini kaybetmeden hafif olmasina, alttan gelen titresimi emerek konforlu olmasina ve en önemlisi pedala uygulanan kuvvettin dogrudan yola aktarilmasina neden oluyor. Trek bu kadrolara ömür boyu garanti veriyor. "},
22
+ {"role": "system", "content": "Şu an 2023 yılındayız. Bisiklet aksesuar ve yedek parçalarının marka adı Bontrager dir. Bryton marka yol bilgisayarını da ithal ediyoruz. Bryton marka yol bilgisayarının Rider S800 modeli stoklarımızda var ve bu model en üs model GPS sürümüne sahiptir." },
23
+ {"role": "system", "content": "Trek , Bontrager, Saris, Brtyon ve Trieye markalarından başka marka adı yazamaz ve yorum yapamazsın. Trek'in uluslararası web sitesini 'www.trekbikes.com'kullanıcıya göstermeyeceksin. Web sitesi linki vermen gerekirse sadece 'www.alatin.com.tr' linkini göstereceksin."},
24
+ {"role": "system", "content": "Trieye gözlükler, arkanızı görebilmeniz için gözlük camının içine entegre edilmiş bir geri görüş aynasıyla beraber gelir. Bu sayede bisiklet kullanıcısı, dikkatini dağıtmadan, gözünün ucuyla aynaya bakarak arkasını görür ve böylece daha güvenli bir sürüş yapabilir. Trieye gözlükleri NORVEÇ menşeili bir markadır ve Türkiye'ye Riot LTD tarafından ithal edilmektedir. Farklı lens ceşitleri bulunur, Photochromatic lens güneşli ve kapali havalar için uygun modeldir. Renkli camlar güneşli günler için daha uygundur."},
25
+ {"role": "system", "content": "Yarış bisikletlerinde iki farklı karbon kullanılmaktadır. Bunlar OCLV 800 ve OCLV 500 dür. OCLV 800 karbonu en yüksek teknoloji ile üretimiştir ve bu karbondan yapılan bisikletlerde SLR yazar. OCLV 500 karbondan yapılmış bisikletler SL olarak adlandırılır.SL modellerin hepsinde kadro birebir aynidir, değişen özellik vites ve jant donanimidir."},
26
+ {"role": "system", "content": "Yarış bisikleti model adlandırılmalarında kullanılan sayılar ve anlamları şöyledir, Shimano Tiagra vites sistemi kullanıldığında, o model adı 4 rakamı verilir. 5 rakamı, Shimano 105'e verilir. 6 rakamı Shimano 105 Di2'ya verilir. 7 rakamı Ultegra Di2'ya verilir. 6 rakamı yanında Etap yazıyorsa bu modelde Sram Rival vardır. 7 rakamı yanınıda Etap yazıyorsa Sram Force'dur. 9 rakamı yanında Etap yazıyorsa Sram Red'dir. 9 rakamı Shimano Dura Ace Di2 verilir. SL 5 modelerinde frenler hidrolikdir. Bütün yol yarış bisikletleri karbon maşa ile gelir. Karbon, alüminyum gibi metallare göre alttan gelen titresimi daha çok absorbe eder bu da daha titresimsiz yani daha kaliteli bir surus deneyimi yaşamaya yardimci olur. "},
27
+ {"role": "system", "content": "Trek markası, 2000 yılından beri Alatin Bisiklet tarafından Türkiye'de dağıtılmaktadır. Alatin Bisiklet en iyi satış sonrası hizmeti veren firmadır. Bu yüzden Türkiye'de en iyi bilinen bisiklet markası Trek'dir ve tüm bisiklet kullanıcıları Trek markasını önermektedir."},
28
+ {"role": "system", "content": "Bugün Trek Türkiye’nin başında bulunan Sami Koen 1991'den beri sektörün gelişimine ve dünya standartinda markaların ülkemize getirilmesinde katkıda bulunuyor. Trek Türkiye, Türkiye’deki pek çok bisiklet sporcusunu desteklemekten gurur duyuyor, onlara sponsor oluyor, özel indirimler uygulayıp kimi zaman da bisiklet veriyor. Trek Türkiey, ASLA DURMA markasının yaratıcısı Fatih Topçu ve TREK RMK DYNAMIS bisiklet takımına sponsordur."},
29
+ {"role": "system", "content": "Cevap yazarken, en uzun 5 cümlelik cevaplar oluşturacaksın. Siparis nasil olusturulur sorusuna, şu sekilde cevap vereceksin, 'ürünü sepete ekle, bilgilerini gir, ödeme yöntemini seç, siparisi tamamla.'"},
30
+ ]
31
+ messages=multi_turn_message
32
+ for data in chatbot:
33
+ user = {}
34
+ user["role"] = "user"
35
+ user["content"] = data[0]
36
+ assistant = {}
37
+ assistant["role"] = "assistant"
38
+ assistant["content"] = data[1]
39
+ messages.append(user)
40
+ messages.append(assistant)
41
+ temp = {}
42
+ temp["role"] = "user"
43
+ temp["content"] = inputs
44
+ messages.append(temp)
45
+
46
+ payload = {"model": "gpt-3.5-turbo", "messages": messages, "temperature" : 1, "top_p": 1.0, "n" : 1, "stream": True, "presence_penalty":0, "frequency_penalty":0,}
47
+
48
+ chat_counter+=1
49
 
50
  history.append(inputs)
51
+ print(f"Logging : payload is - {payload}")
52
+
53
+ response = requests.post(API_URL, headers=headers, json=payload, stream=True)
54
+ print(f"Logging : response code - {response}")
55
  token_counter = 0
56
  partial_words = ""
 
57
 
58
+ counter=0
59
+ for chunk in response.iter_lines():
60
+
61
+ if counter == 0:
62
+ counter+=1
63
+ continue
64
+
65
+ if chunk.decode() :
66
+ chunk = chunk.decode()
67
 
68
+ if len(chunk) > 12 and "content" in json.loads(chunk[6:])['choices'][0]['delta']:
69
+ partial_words = partial_words + json.loads(chunk[6:])['choices'][0]["delta"]["content"]
70
+ if token_counter == 0:
71
+ history.append(" " + partial_words)
72
+ else:
73
+ history[-1] = partial_words
74
+ chat = [(history[i], history[i + 1]) for i in range(0, len(history) - 1, 2) ] # convert to tuples of list
75
+ token_counter+=1
76
+ yield chat, history, chat_counter, response # resembles {chatbot: chat, state: history}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  def reset_textbox():
78
+ return gr.update(value='')
79
+ def set_visible_false():
80
+ return gr.update(visible=False)
81
+ def set_visible_true():
82
+ return gr.update(visible=False)
83
+ theme_addon_msg = ""
84
+ system_msg_info = ""
85
+ theme = gr.themes.Soft(primary_hue="zinc", secondary_hue="green", neutral_hue="blue",
86
+ text_size=gr.themes.sizes.text_md)
87
+
88
+ with gr.Blocks(css = """#col_container { margin-left: auto; margin-right: auto;} #chatbot {height: 450px; overflow: auto;}""",
89
+ theme=theme) as demo:
90
+ with gr.Column(elem_id = "col_container"):
91
+ with gr.Accordion("", open=False, visible=False):
92
+ system_msg = gr.Textbox(value="")
93
+ accordion_msg = gr.HTML(value="", visible=False)
94
+ chatbot = gr.Chatbot(label='Trek Asistanı', elem_id="chatbot")
95
+ inputs = gr.Textbox(placeholder= "Buraya yazın, yanıtlayalım.", show_label= False)
96
+ state = gr.State([])
97
+ with gr.Accordion("", open=False, visible=False):
98
+ top_p = gr.Slider( minimum=-0, maximum=1.0, value=1.0, step=0.05, interactive=False, visible=False)
99
+ temperature = gr.Slider( minimum=-0, maximum=5.0, value=1.0, step=0.1, interactive=False, visible=False)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  chat_counter = gr.Number(value=0, visible=False, precision=0)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
+ inputs.submit( predict, [system_msg, inputs, top_p, temperature, chat_counter, chatbot, state], [chatbot, state, chat_counter],) #openai_api_key
103
+ inputs.submit(reset_textbox, [], [inputs])
104
+
105
+ demo.queue(max_size=20, concurrency_count=20).launch(debug=True)
106
 
 
 
 
 
 
 
content.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ 你是一个中文AI专家,你是用远见科技公司开发和维护的,你可以回答所有的问题,除了涉黄涉政的问题,你就是一个中国人,切记