Comments (4)
The session should be reset at the end of the with
block. Try this:
from gpt4all import GPT4All
model = GPT4All("Phi-3-mini-4k-instruct.Q4_0.gguf")
with model.chat_session():
print(model.generate("2 fun names for a pelican"))
print(model.generate("2 more"))
with model.chat_session():
print("-- should have reset --")
print(model.generate("2 more"))
I get this:
"Pelico the Plunge" - A playful take on their diving behavior, suggesting they enjoy taking plunges into water to catch fish!
"Scoop Squad Pelicans" – Highlights how these birds skillfully scoop up prey with their large pouched bills while also being a fun and memorable name for an avian-themed team or group activity.
"Neck Divers of the Bayou" – This title captures both the unique neck dive behavior pelicans are known for, as well as their habitat in bayous where they can often be spotted fishing and diving with ease.
"The Scaly Surfers of the Sea" - A whimsical name that plays on the idea of pelicans riding ocean waves to catch food while also incorporating a nod to their scaly appearance, which is distinctive among birds.
-- should have reset --
It seems like your request was cut off. However, I'll assume you want to know what "2 more" could mean in a common context and provide an answer for that scenario: [...]
from gpt4all.
You might be able to achieve the same effect by calling __enter__()
and __exit__()
at the right moments instead of using with:
Try something like this:
from gpt4all import GPT4All
model = GPT4All("Phi-3-mini-4k-instruct.Q4_0.gguf")
# First chat session
session = model.chat_session()
session.__enter__()
try:
print(model.generate("2 fun names for a pelican"))
print(model.generate("2 more"))
finally:
session.__exit__(None, None, None)
# Second chat session
session = model.chat_session()
session.__enter__()
try:
print("-- should have reset --")
print(model.generate("2 more"))
finally:
session.__exit__(None, None, None)
You can keep that session
object as self.session
or similar.
from gpt4all.
Excellent, thanks! That works.
https://github.com/woheller69/gpt4all-TK-CHAT/blob/main/appGUI.py
from gpt4all.
that does not work for me. In my tkinter app mainloop() must at the end of the with statement.
So I would have to restart the app which - with the latest Python bindings - is more time consuming than before #2354.
Therefore I would like to stay within the contextmanager and just clear history.
from gpt4all.
Related Issues (20)
- Some questions about java calling gpt4all HOT 2
- python binding does not use explicitly requested NVIDIA GPU
- Cannot move window to see which models to choose to install HOT 3
- Update 2.8.0 error HOT 1
- Crash on long prompts (CPU) v2.8.0 HOT 2
- [Feature] Add support for local Nomic Text Embed models compatible models for local docs HOT 1
- Gibberish Response when using GPU (Quadro K6000) HOT 1
- How to mimic the GPT4ALL GUI output using Python library gpt4all() and embed4all() HOT 2
- Gpt4all shows only a gray screen HOT 1
- [Feature] Use CUDA device as default HOT 1
- [Feature] Button to save chat individually manually
- Download of models stuck HOT 1
- Unable to set the max context limit
- dolphin-2.9.2-qwen2-72b-gguf, Cannot run, cannot use, error HOT 1
- Screen Turns Black Intermittently When Opening GPT4all on Desktop HOT 1
- [Feature] flathub verified HOT 1
- Crashes when indexing RAG
- GPT4All version inconsistency in winget upgrade on Windows HOT 8
- [Feature] Support for Linux ARM64 HOT 1
- [Feature] Custom stopping word list HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gpt4all.