From 5ec9d3f7b59c6e61635ce38d720855523218d39e Mon Sep 17 00:00:00 2001 From: cyclop-bot <178948048+cyclop-bot@users.noreply.github.com> Date: Mon, 28 Oct 2024 10:15:43 -0500 Subject: [PATCH] Initialize standalone LLM tool with basic class structure. --- standalone_llm_tool.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 standalone_llm_tool.py diff --git a/standalone_llm_tool.py b/standalone_llm_tool.py new file mode 100644 index 0000000..3dac90e --- /dev/null +++ b/standalone_llm_tool.py @@ -0,0 +1,33 @@ +import os +import json +import logging +from openai import OpenAI + +class StandaloneLLMTool: + def __init__(self): + self.client = OpenAI(api_key=os.environ.get("OPENAI_API_KEY")) + self.model = "llm-preview" + self.max_tokens = 16384 + + def get_detailed_instructions(self, user_prompt): + response = self.client.completions.create( + model=self.model, + prompt=user_prompt, + max_tokens=self.max_tokens + ) + return response + + def process_user_input(self, user_prompt): + logging.info(f"Received prompt: {user_prompt}") + response = self.get_detailed_instructions(user_prompt) + logging.info("Response generated") + return response.choices[0].text + +def main(): + tool = StandaloneLLMTool() + user_prompt = input("Enter your prompt: ") + response = tool.process_user_input(user_prompt) + print("Response:", response) + +if __name__ == '__main__': + main()