+ 1

Ai assistant

How to further the program of my ai assistant

24th Sep 2024, 7:57 PM
Phantom-Lord
Phantom-Lord - avatar
4 Respuestas
+ 4
Step 1 is to get the sample code. You have that. Step 2 is to get your openai api key. - go to openai.com - create / login to your account. - go to your DASHBOARD - on the left, go to API keys - create your secret key and copy it somewhere safe. Step 3 - don't put the API key in your code (best practice). Put it in a .env file and use the package: python-dotenv Step 4 - update the sample code to use the dotenv and get your key variable loaded. Then you can successfully run the sample code. Step 5 - Now that the code works - you can start to structure your prompts. Experiment with that. Step 6 - Learn to request results from a prompt in JSON format. You have to specify it in your query and in your request. Then you can ask for things in a way that you can programmatically work with your results. By this stage, you are ready to construct a chat interface or a programming interface depending on what you want to do. A programming interface would be to return data or a chat interface would be to return conversational results. Finally, you can look at training. Training is a challenge. ChatGPT has two different input formats depending on the engine you are using. But you can ASK chatgpt questions about that as well. You'll need to prepare a bunch of prompt / response entries in JSON format to use for the training. In my case, I decided to make Markdown files (MD) with my responses and put the PROMPTS in the heading of those documents. Then I wrote a python script to extract the prompt and responses out of all those files and generate one JSONL file with everything in it. That JSONL file is what ChatGPT reads for the training. Finally I uploaded that to ChatGPT and asked it: "Please review my JSONL file for any errors. Give me feedback on improvements." etc. In my case, it pointed out some issues and inconsistencies in my responses. It was beautiful.
24th Sep 2024, 9:21 PM
Jerry Hobby
Jerry Hobby - avatar
+ 3
you could make a graphical user interface for example.
24th Sep 2024, 9:16 PM
Lisa
Lisa - avatar
+ 2
What have you done so far?
24th Sep 2024, 8:52 PM
Lisa
Lisa - avatar
+ 2
pip install openai import openai openai.api_key = "YOUR_API_KEY" def chat_with_ai(): conversation = [{"role": "system", "content": "You are a helpful assistant."}] while True: user_input = input("You: ") if user_input.lower() in ["exit", "quit"]: break conversation.append({"role": "user", "content": user_input}) response = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=conversation ) assistant_reply = response.choices[0].message["content"] print(f"Assistant: {assistant_reply}") conversation.append({"role": "assistant", "content": assistant_reply}) if __name__ == "__main__": chat_with_ai()
24th Sep 2024, 8:54 PM
Phantom-Lord
Phantom-Lord - avatar