Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
yandricr authored Apr 17, 2024
1 parent 5800d90 commit bae7f50
Show file tree
Hide file tree
Showing 3 changed files with 580 additions and 161 deletions.
168 changes: 165 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ pip install gpti
GPTI provides access to a variety of artificial intelligence models to meet various needs. Currently, the available models include:

- [**ChatGPT**](#gpt)
- [**ChatGPT v2**](#gpt-v2)
- [**ChatGPT Web**](#gptweb)
- [**ChatGPT Prompts**](#gpt-prompts)
- [**Bing**](#bing)
- [**LLaMA-2**](#llama2)
- [**DALL·E**](#dalle)
Expand Down Expand Up @@ -55,7 +57,7 @@ nexra("user-xxxxxxxx", "nx-xxxxxxx-xxxxx-xxxxx");
import json
from gpti import gpt

res = gpt(messages=[
res = gpt.v1(messages=[
{
"role": "assistant",
"content": "Hello! How are you today?"
Expand Down Expand Up @@ -116,16 +118,117 @@ Select one of these available models in the API to enhance your experience.
- babbage-002
- davinci-002

<a id="gpt-v2"></a>
## Usage GPT v2

It's quite similar, with the difference that it has the capability to generate real-time responses via streaming using gpt-3.5-turbo.

```python
import json
from gpti import gpt

res = gpt.v2(messages=[
{
"role": "assistant",
"content": "Hello! How are you today?"
},
{
"role": "user",
"content": "Hello, my name is Yandri."
},
{
"role": "assistant",
"content": "Hello, Yandri! How are you today?"
},
{
"role": "user",
"content": "Can you repeat my name?"
}
], markdown=False, stream=False)

if res.error != None:
print(json.dumps(res.error))
else:
print(json.dumps(res.result))
```

#### JSON

```json
{
"code": 200,
"status": true,
"model": "ChatGPT",
"message": "Of course, Yandri! How can I assist you today?",
"original": null
}
```

## Usage GPT v2 Streaming

```python
import json
from gpti import gpt

res = gpt.v2(messages=[
{
"role": "assistant",
"content": "Hello! How are you today?"
},
{
"role": "user",
"content": "Hello, my name is Yandri."
},
{
"role": "assistant",
"content": "Hello, Yandri! How are you today?"
},
{
"role": "user",
"content": "Can you repeat my name?"
}
], markdown=True, stream=False)

if res.error != None:
print(json.dumps(res.error))
else:
for chunk in res.stream():
print(json.dumps(chunk))
```

#### JSON

```json
{"message":"Hello! How are you today?","original":null,"finish":false,"error":false}
{"message":"","original":null,"finish":false,"error":false}
{"message":"Of","original":null,"finish":false,"error":false}
{"message":"Of course","original":null,"finish":false,"error":false}
{"message":"Of course,","original":null,"finish":false,"error":false}
{"message":"Of course, Yand","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri!","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can I","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can I assist","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can I assist you","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can I assist you today","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can I assist you today?","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can I assist you today?","original":null,"finish":false,"error":false}
{"message":"Of course, Yandri! How can I assist you today?","original":null,"finish":false,"error":false}
{"message":null,"original":null,"finish":true,"error":false}
```

<a id="gptweb"></a>
## Usage GPT Web

GPT-4 has been enhanced by me, but errors may arise due to technological complexity. It is advisable to exercise caution when relying entirely on its accuracy for online queries.

```python
import json
from gpti import gptweb
from gpti import gpt

res = gptweb(prompt="Are you familiar with the movie Wonka released in 2023?", markdown=False)
res = gpt.web(prompt="Are you familiar with the movie Wonka released in 2023?", markdown=False)

if res.error != None:
print(json.dumps(res.error))
Expand All @@ -144,6 +247,65 @@ else:
}
```

<a id="gpt-prompts"></a>
## Usage GPT Prompts

```python
import json
from gpti import gpt

res = gpt.prompts(lang="en", limit=4, offset=0)

if res.error != None:
print(json.dumps(res.error))
else:
for chunk in res.stream():
print(json.dumps(chunk))
```

#### JSON

```json
{
"code": 200,
"status": true,
"items": [
{
"id": "e90a6598",
"title": "Suggest fun activities",
"description": "to do indoors with my high-energy dog",
"prompt": "What are five fun and creative activities to do indoors with my dog who has a lot of energy?",
"category": "idea"
},
{
"id": "974d4604",
"title": "Help me pick",
"description": "a birthday gift for my mom who likes gardening",
"prompt": "Help me pick a birthday gift for my mom who likes gardening. But don't give me gardening tools – she already has all of them!",
"category": "shop"
},
{
"id": "d1c0099d",
"title": "Help me study",
"description": "vocabulary for a college entrance exam",
"prompt": "Help me study vocabulary: write a sentence for me to fill in the blank, and I'll try to pick the correct option.",
"category": "teach-or-explain"
},
{
"id": "a36cb799",
"title": "Write a letter to future me",
"description": "reflecting on my mental health",
"prompt": "Can you help me craft a letter to my future self? Start by asking me about the key milestones and struggles in my mental health journey I'd like to include.",
"category": "write"
}
],
"total": 4,
"limit": 4,
"offset": 0,
"lang": "en"
}
```

<a id="bing"></a>
## Usage Bing

Expand Down
Loading

0 comments on commit bae7f50

Please sign in to comment.