Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5c64a71
Added new feature in the existing GST calculator
tanujbordikar Aug 4, 2023
0b9e78c
Added new feature in the existing GST calculator
tanujbordikar Aug 4, 2023
2cffc8f
Improved the calculator by using tkinter
tanujbordikar Aug 4, 2023
0ad6ecc
added the screenshot with tkinter gui and also created a new document…
tanujbordikar Aug 5, 2023
369dcbe
added techCrunch.py
Mihan786Chistie Aug 5, 2023
af89634
updated techCrunch.py
Mihan786Chistie Aug 5, 2023
f1ae4ed
updated techCrunch.py
Mihan786Chistie Aug 5, 2023
58c7c6d
added README.md
Mihan786Chistie Aug 5, 2023
3f15a8f
updated techCrunch.py
Mihan786Chistie Aug 5, 2023
2dc2121
added requirements.txt
Mihan786Chistie Aug 5, 2023
e5d8c91
Pixel Art Generator Script Added
andoriyaprashant Aug 5, 2023
eeda4e1
Lint Fix
andoriyaprashant Aug 5, 2023
ac34009
culturally-inspired names imaginary
Swapnil-2503 Aug 5, 2023
66af624
morphological transformations
invigorzz313 Aug 5, 2023
31a905e
Infinite Runner with Obstacles Script Added
andoriyaprashant Aug 5, 2023
46c36bf
Gomoku_game.py
Shikhar9425 Aug 6, 2023
ac814f2
README.md
Shikhar9425 Aug 6, 2023
0171cee
Adding code, README file
MrResilient Aug 8, 2023
2328db2
Adding code, README file
MrResilient Aug 8, 2023
8a9853c
Merge branch 'cont1' of https://github.com/Shivansh-Jain-github/Amazi…
MrResilient Aug 8, 2023
eec9f8b
Merge pull request #2687 from Shivansh-Jain-github/master
1e9abhi1e10 Aug 8, 2023
14d473a
Merge pull request #2686 from Shivansh-Jain-github/cont1
1e9abhi1e10 Aug 8, 2023
a741426
Completed payment receipt project
Yashika-Agrawal Aug 8, 2023
2d2d94b
Merge pull request #2691 from Yashika-Agrawal/Payment
1e9abhi1e10 Aug 8, 2023
3250119
Adding code, README.md file
MrResilient Aug 8, 2023
84f20e8
Adding code, README.md file
MrResilient Aug 8, 2023
83f766a
Add commit
MrResilient Aug 8, 2023
51cf405
Delete
MrResilient Aug 8, 2023
fabfd2c
delete
MrResilient Aug 8, 2023
034c8d4
Merge pull request #2696 from Shivansh-Jain-github/CONT1
1e9abhi1e10 Aug 8, 2023
42b6943
Merge pull request #2695 from Shivansh-Jain-github/cont1
1e9abhi1e10 Aug 8, 2023
2efacbb
Merge pull request #2668 from Shikhar9425/master-8
1e9abhi1e10 Aug 8, 2023
57fe6d4
Merge pull request #2639 from Swapnil-2503/culturally-inspired-names
1e9abhi1e10 Aug 8, 2023
bfb1e89
Merge pull request #2635 from Mihan786Chistie/techCrunch
1e9abhi1e10 Aug 8, 2023
b25ce3d
Merge pull request #2650 from andoriyaprashant/branch28
1e9abhi1e10 Aug 8, 2023
a9dee15
Merge pull request #2637 from andoriyaprashant/branch27
1e9abhi1e10 Aug 8, 2023
8890205
Merge pull request #2640 from invigorzz313/morphtransforms
1e9abhi1e10 Aug 8, 2023
148eaea
Merge pull request #2631 from tanujbordikar/screenshot
1e9abhi1e10 Aug 8, 2023
4d01156
True False Automation
MrResilient Aug 8, 2023
c58725c
WhatsApp_timer_messenger code
MrResilient Aug 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add commit
  • Loading branch information
MrResilient committed Aug 8, 2023
commit 83f766a8921198477a4db9888653272ac3ce0e4a
96 changes: 96 additions & 0 deletions Chatbot using ChatGPT OpenAI key/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
```markdown
# ChatGPT Usage Example

This repository contains an example of how to use OpenAI's GPT-3.5-turbo model for interactive text-based conversations. In this example, you'll learn how to use both the OpenAI Python Package and the API Endpoint to engage in a conversation with the language model.

## Installation

You'll need to install the OpenAI Python package to use the GPT-3.5-turbo model. You can do this using the following command:

```bash
pip install -q openai
```

## Usage

### Method 1 - Using OpenAI Python Package

```python
import openai

# Set your OpenAI API key
openai.api_key = 'your-api-key'

# Initialize the conversation with a system message
messages = [
{"role": "system", "content": "You are a kind helpful assistant."},
]

while True:
message = input("User : ")
if message:
messages.append(
{"role": "user", "content": message},
)
chat = openai.ChatCompletion.create(
model="gpt-3.5-turbo", messages=messages
)

reply = chat.choices[0].message.content
print(f"ChatGPT: {reply}")
messages.append({"role": "assistant", "content": reply})
```

Example conversation:

```
User : What is your name?
ChatGPT: I am a language model developed by OpenAI, and I don't have a specific name. You can call me OpenAI if you'd like. How can I assist you further?
User : Can you call me Shivansh?
ChatGPT: Sure, Shivansh. Is there anything else I can help you with?
User : What is my name?
ChatGPT: Your name is Shivansh.
```

### Method 2 - Using API Endpoint

```python
import requests

# Set your OpenAI API key
api_key = 'your-api-key'

URL = "https://api.openai.com/v1/chat/completions"

payload = {
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": f"What is the first computer in the world?"}],
"temperature": 1.0,
"top_p": 1.0,
"n": 1,
"stream": False,
"presence_penalty": 0,
"frequency_penalty": 0,
}

headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}

response = requests.post(URL, headers=headers, json=payload, stream=False)
result = response.json()
assistant_reply = result["choices"][0]["message"]["content"]
print(f"Assistant's reply: {assistant_reply}")
```

Example response:

```
Assistant's reply: The first computer in the world was the Electronic Numerical Integrator and Computer (ENIAC), created in 1945 at the University of Pennsylvania.
```

Feel free to experiment with the provided code and adapt it to your specific use case. For more information about the OpenAI API and its capabilities, refer to the [official documentation](https://beta.openai.com/docs/).
```

Please replace `'your-api-key'` with your actual OpenAI API key before using the code.
87 changes: 87 additions & 0 deletions Chatbot using ChatGPT OpenAI key/script1.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"\n",
"!pip install -q openai "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"import openai"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"openai.api_key = 'sk-'"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"messages = [\n",
" {\"role\": \"system\", \"content\": \"You are a kind helpful assistant.\"},\n",
"]"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"while True:\n",
" message = input(\"User : \")\n",
" if message:\n",
" messages.append(\n",
" {\"role\": \"user\", \"content\": message},\n",
" )\n",
" chat = openai.ChatCompletion.create(\n",
" model=\"gpt-3.5-turbo\", messages=messages\n",
" )\n",
" \n",
" reply = chat.choices[0].message.content\n",
" print(f\"ChatGPT: {reply}\")\n",
" messages.append({\"role\": \"assistant\", \"content\": reply})"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}
51 changes: 51 additions & 0 deletions Chatbot using ChatGPT OpenAI key/script2.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import requests\n",
"\n",
"URL = \"https://api.openai.com/v1/chat/completions\"\n",
"\n",
"payload = {\n",
"\"model\": \"gpt-3.5-turbo\",\n",
"\"messages\": [{\"role\": \"user\", \"content\": f\"What is the first computer in the world?\"}],\n",
"\"temperature\" : 1.0,\n",
"\"top_p\":1.0,\n",
"\"n\" : 1,\n",
"\"stream\": False,\n",
"\"presence_penalty\":0,\n",
"\"frequency_penalty\":0,\n",
"}\n",
"\n",
"headers = {\n",
"\"Content-Type\": \"application/json\",\n",
"\"Authorization\": f\"Bearer {openai.api_key}\"\n",
"}\n",
"\n",
"response = requests.post(URL, headers=headers, json=payload, stream=False)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"\n",
"response.content"
]
}
],
"metadata": {
"language_info": {
"name": "python"
},
"orig_nbformat": 4
},
"nbformat": 4,
"nbformat_minor": 2
}