Comments (6)
I currently am using GPT4ALL and Jan which both support api access. I'd love to try this with those.
from plandex.
Thanks @michaellatman -- I agree. Adding more flexibility here is a priority.
from plandex.
Here is my code to send a prompt to Jan in case that is useful for you to see:
import requests
import json
from datetime import datetime
from tqdm import tqdm
class JanPrompt:
def __init__(self, ip_address, port, agent_message, command_message):
self.ip_address = ip_address
self.port = port
self.agent_message = agent_message
self.command_message = command_message
self.url = f"http://{self.ip_address}:{self.port}/v1/chat/completions"
def compose_payload(self):
payload = {
"messages": [
{"content": self.agent_message, "role": "system"},
{"content": self.command_message, "role": "user"}
],
"model": "mistral-ins-7b-q4",
"stream": True,
"max_tokens": 2048,
"stop": ["hello"],
"frequency_penalty": 0,
"presence_penalty": 0,
"temperature": 0.7,
"top_p": 0.95
}
return payload
def send_prompt(self):
headers = {'Content-Type': 'application/json'}
payload = self.compose_payload()
response = requests.post(self.url, headers=headers, data=json.dumps(payload), stream=True)
return self.handle_stream(response)
def handle_stream(self, response):
final_data = ""
content_pieces = []
progress_bar = tqdm(unit="chunk", desc="Receiving data")
try:
for line in response.iter_lines():
if line:
decoded_line = line.decode('utf-8')
progress_bar.update(1)
if decoded_line == "data: [DONE]":
break
data_json = json.loads(decoded_line.replace("data: ", ""))
if "choices" in data_json:
for choice in data_json["choices"]:
if "delta" in choice and "content" in choice["delta"]:
content_pieces.append(choice["delta"]["content"])
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
finally:
progress_bar.close()
final_data = "".join(content_pieces)
return final_data
def save_to_file(self, response_data):
timestamp = datetime.now().strftime("%Y%m%d%H%M%S")
filename = f"prompt_result_{timestamp}.md"
with open(filename, 'w') as file:
file.write(f"## Agent Message\n\n{self.agent_message}\n\n## Command Message\n\n{self.command_message}\n\n## Response\n\n{response_data}")
print(f"Saved to {filename}")
def run(self):
response_data = self.send_prompt()
self.save_to_file(response_data)
if __name__ == "__main__":
ip_address = "localhost"
port = 1337 # Replace with the actual port number
agent_message = "You are a helpful assistant."
command_message = "Please give me a recipe for steamed hams."
jan_prompt = JanPrompt(ip_address, port, agent_message, command_message)
jan_prompt.run()
from plandex.
Thanks @richard-schwab. Unfortunately as with ollama it looks like Jan doesn't support the tools
parameter for function-calling, which Plandex relies on.
from plandex.
👍 I was immediately looking into trying this with https://github.com/go-skynet/LocalAI - would be great if we can set up an OPENAI_ENDPOINT
from plandex.
Fixed by #46 and just released in server/0.8.3 and cli/0.8.2
from plandex.
Related Issues (20)
- 🚨 Error removing temporary file → Remove C:\Users\Admin\AppData\Local\Temp\plandex_prompt_498749288 → The process cannot access the file because it is being used by another process. HOT 3
- [ubuntu] docker-compose up (for the very first time) throws errors
- index out of range [1] with length 1 HOT 1
- Create New user/org on Plandex Cloud fails to automatically log in HOT 1
- `plandex models add` doesn't offer openrouter when it should
- Api base url should be required when adding a custom model HOT 2
- Ctrl-C after a 'tell' loses the prompt HOT 1
- No Account Registration Links Available on Plandex.ai for Plandex Cloud Service HOT 1
- Silent failure to upgrade after the cli prompted me to HOT 3
- The term 'plandex' is not recognized as a name of a cmdlet, function, script file, or executable program. HOT 1
- [Again] Feature Request: Support for Azure OpenAI API HOT 1
- Server error setting max tokens HOT 3
- Add gpt-4o HOT 1
- Add option to install via Homebrew
- Support for OpenRouter HOT 2
- How to uninstall? HOT 1
- no changes pending HOT 3
- Automatic CLI upgrade isn't working in some cases HOT 3
- prepareEditorCommand doesn't accept arguments HOT 4
- Self-host - Easy solve for email verification error 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 plandex.