jmikedupont2 / ai-ticket

The AI and Human powered ticket system to manage your AI based code generation with tickets
MIT License
21 stars 11 forks source link

test user ticket #30

Open Deadsg opened 11 months ago

Deadsg commented 11 months ago

import torch from transformers import GPT2LMHeadModel, GPT2Tokenizer

class AutoGPTAgent: def init(self): self.commands = { "generate": self.generate_text,

Add more commands as needed

    }
    self.tokenizer = GPT2Tokenizer.from_pretrained("gpt2")
    self.model = GPT2LMHeadModel.from_pretrained("gpt2")

def generate_text(self, args):
    # Join the arguments into a single string
    prompt = " ".join(args)

    # Encode the prompt and generate the text
    inputs = self.tokenizer.encode(prompt, return_tensors="pt")
    outputs = self.model.generate(inputs, max_length=100, temperature=0.7)

    # Decode the generated text and print it
    generated_text = self.tokenizer.decode(outputs[0])
    print(generated_text)

def process_command(self, command, args):
    if command in self.commands:
        self.commandscommand
    else:
        print(f"Unknown command: {command}")

Usage:

agent = AutoGPTAgent() agent.process_command("generate", ["Hello, world!"])

jmikedupont2 commented 10 months ago

/agent-action update test

jmikedupont2 commented 10 months ago

/agent-action sweep the floor

jmikedupont2 commented 10 months ago

/agent-action regulate

jmikedupont2 commented 10 months ago

/agent-action regulate2