library for easy access to GPT models based on g4f
Project description
g4f_xn
A library that allows you to use different GPT models!
Also has some other stuff like:
- reading and writing to files
- sound playback(i mean why not)
- other functions for convenience
The project is not ready for public use, but more for a fun and convinient (in my opinion) use of gpt models
code example:
import g4f_xn as xn
# specify model
xn.settings('gpt-3.5-turbo')
prompt = '''
type numbers from 1 to 10
'''
result = xn.gpt(prompt)
print(result)
also you can provide an array to xn.gpt that will represent history of previous prompts and answers. It will use it as context and append prompt with response.
advanced example:
import g4f_xn as xn
# specify model and provider
xn.settings('gpt-4', 'Bing')
p1 = '''
type numbers from 1 to 10
'''
p2 = '''
multiply each number by 2
'''
chat = []
r1 = xn.gpt(p1, chat)
r2 = xn.gpt(p2, chat)
print(r1) # 1, 2, 3, ...
print(r2) # 2, 4, 6, ...
gpt -> chat gpt
You can also save chat variable to txt file using xn.write, xn.read
it will be basically chatgpt now
example with local chat history:
import g4f_xn as xn
xn.settings('gpt-3.5-turbo')
history = xn.read(r'path/to/file.txt')
chat = [history]
prompt = '''
type numbers from 1 to 10
'''
result = xn.gpt(prompt, chat)
print(result)
xn.write(''.join(chat), r'path/to/file.txt')
It is highly recommended to use .ipynb files with this library as it is really flexible for that task
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file g4f_xn-0.0.6.tar.gz
.
File metadata
- Download URL: g4f_xn-0.0.6.tar.gz
- Upload date:
- Size: 623.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ddfd003af81fb608a44fa23e06ca80e1b9f6414b0afa75eca2fb5ddecc470683 |
|
MD5 | 65c2d4d58e4365ea553239da73e021f8 |
|
BLAKE2b-256 | 51391371d649719988e42dfd8b032b5451efe9e53098c204166fbaed13732cc2 |
File details
Details for the file g4f_xn-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: g4f_xn-0.0.6-py3-none-any.whl
- Upload date:
- Size: 621.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 07e58b6598ef8c7b20e2bcbedbef95039bdc711e59170356099743994c3aae8b |
|
MD5 | 69a8c04c207f89e6871165bd0c202775 |
|
BLAKE2b-256 | 64563aae281c1256413ebaae623f7b6190d05c9a3c02651e7516c1e4df468cce |