I just set up a new dedicated AI server that is quite fast by my standards. I have it running with OpenWebUI and would like to integrate it with other services. I think it would be cool to have something like copilot where I can be writing code in a text editor and have it add a readme function or something like that. I have also used some RAG stuff and like it, but I think it would be cool to have a RAG that can access live data, like having the most up to date docker compose file and nginx configs for when I ask it about server stuff. So, what are you integrating your AI stuff with, and how can I get started?

  • SmokeyDope@lemmy.worldM
    link
    fedilink
    English
    arrow-up
    0
    ·
    edit-2
    4 days ago

    If your running into the issue of an app wanting an api key for your local ollamas openai-compatable web interface API and refuses to work without one, I found that any random characters work. If you port forward your host computer you should be able to access the webui interface on an external network using the public IP.

    Heres the dead simple python program I used to send and recieve text to kobold.cpp engine through the web API. Not sure how similar ollama but afaik openai-compatable API means it all should works close to the same for compatibility(I think? lol!) if you give it a shot Make sure to set the .py file you make as executable and run it from a terminal doing ./filename.py to see the output in real time. It should make a log text file in same dir as the program too. Just use your host computers local ip if the python script pc is on same network.

    spoiler
    import requests
    
    # Configuration
    API_URL = "http://10.0.0.xx:5001/api/v1/generate"
    PROMPT = "Tell me a short story about a robot learning to dance."
    OUTPUT_FILE = "output.txt"
    
    # Define the API request data
    data = {
        "prompt": PROMPT,
        "max_length": 200,      # Adjust response length
        "temperature": 0.7,     # Control randomness (0=deterministic, 1=creative)
        "top_p": 0.9,           # Focus on high-probability tokens
    }
    
    # Send the request to kobold.cpp
    response = requests.post(API_URL, json=data)
    
    if response.status_code == 200:
        # Extract the generated text
        result = response.json()
        generated_text = result["results"][0]["text"]
        
        # Save to a text file
        with open(OUTPUT_FILE, "w") as f:
            f.write(generated_text)
        print(f"Response saved to {OUTPUT_FILE}!")
    else:
        print(f"Error: {response.status_code} - {response.text}")