#Problem with API and telegram.

51 messages · Page 1 of 1 (latest)

gusty mauve
#

Im working on gpt bot for telegram, but only response what im getting is "id"
Does somebody have any idea?

royal belfry
#

Can you share the full request and the response?

gusty mauve
#

Tomorrow will send code

royal belfry
#

kk, yeah would help to see the code and response

gusty mauve
# royal belfry kk, yeah would help to see the code and response

import json
import os
import openai
import telebot
from telebot import types
bot = telebot.TeleBot("KEY")

@bot.message_handler(content_types=["text"])
def get_text_messages(message):
json_message = json.loads(json.dumps(str(message)))
#print(type(message))
#print(type(json_message))
start_sequence = "\nAI:"
restart_sequence = "\nHuman: "
openai.api_key = os.getenv("KEY")
openai.api_key = ("KEY")
response = openai.Completion.create(
model="text-davinci-003",
prompt= json_message,
temperature=0.9,
max_tokens=150,
top_p=1,
frequency_penalty=0,
presence_penalty=0.6,
stop=[" Human:", " AI:"]
)
bot.send_message(message.chat.id, response)
bot.polling(none_stop=True, interval=0)

#

response:

lean zinc
#

you need to locate to the text in the response

#

In javascript it’s response.data.choices[0].text

#

instead of just a ‘response’

gusty mauve
gusty mauve
lean zinc
#

why not ask chatgpt to convert this to python

#

response.choices[0].text.strip()

#

try this

lean zinc
gusty mauve
#

im getting muted for not speaking english

lean zinc
#

I think it will work

gusty mauve
#

now its sending information about me

#

its progress

gusty mauve
gusty mauve
#

i tryed without telegram

#

yeeee

lean zinc
# gusty mauve

Emm since the knowledge base of chatGPT is cut by 2021, some of its knowledge might be outdated

gusty mauve
gusty mauve
#

whyyyy

#

@lean zinc @royal belfry any ideas?

royal belfry
#

Looks like the prompt you gave it was bad @gusty mauve

#

What was the prompt?

gusty mauve
lean zinc
#

prompt should be something like this if you are making a chat bot:

#

The following is a conversation between Human and AI.

#

Human: hello

#

AI: hi there

#

Human:

#

then add your message after the Human:

#

then, add a AI: after that

#

Finally the prompt is:

#

The following is a conversation between Human and AI.

#

Human: Hello

#

AI: hi there

#

Human: (your message)

#

AI:

#

please note that the use of api is much different from chatgpt, it cannot store your message and don’t know wha to do if you do not give it an exact instruction