Skip to main content

A thin wrapper around `ollama` library

Project description

OllamAgent

OllamAgent is a wrapper aroundn Ollama API. Ollama is a mini framework for consuming, managing and maintaining SOTA (State of the Art) Large Language Models that have been Quantaized and optimized for deployment on edge devices, there is no need for 'OpenAI' or 'HuggingFace' API keys, or even 'API_KEY' for that matter, you can run these models within your own devices ensuring data privacy, security and most importantly accesibility to this cutting edge technology for people with limited resources. It implements an Agent | Tools mini-framework that simplifies the ussage of the full set of features of the supported models (Currently only Mistral7B is supported).

Installation

pip install ollamagent

Usage

from ollamagent import APIClient, Agent, Tool

# Implementing an integration with a third party API
class MyAPI(APIClient):
	base_url = "https://api.myapi.com"
	headers = {
		"Authorization": "Bearer MY_API_KEY"
	}
 
	async def my_api_method(self, data):
		return await self.post("/my-api-method", data)

# Implementing a tool
class MyTool(Tool):
	data: dict

	@property
	def api(self):
		return MyAPI()
	
	async def run(self):
		return await self.api.my_api_method(self.data)

# Instantiating the agent
agent = Agent(tools=[MyTool])

# Interacting with the agent
async def main():
	print(await agent.chat(message="Hello! Are you there?"))
	>>> "Hello! I'm here, how can I help you?"
	print(await agent.run_tool("MyTool", data={"key": "value"}))
	>>> {"response": "from", "my": "api"}
 
asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ollamagent-0.0.4.tar.gz (10.6 kB view details)

Uploaded Source

Built Distribution

ollamagent-0.0.4-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file ollamagent-0.0.4.tar.gz.

File metadata

  • Download URL: ollamagent-0.0.4.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for ollamagent-0.0.4.tar.gz
Algorithm Hash digest
SHA256 516d510722b2c6edc8b7706d30dee3b55094e0202963360dffa9f89475159e5e
MD5 3f7d6d6b4a084658e36afa46bf898764
BLAKE2b-256 82446780134c51ccd4c376ce4e4a018707ba8dfd085843fcd00fd8908effab53

See more details on using hashes here.

File details

Details for the file ollamagent-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: ollamagent-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.12.1 Darwin/23.2.0

File hashes

Hashes for ollamagent-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 354f67d0af5be6a78f0f9113587d6b941dfdf1f935867d3f280cd44a6aa057b1
MD5 9c7371f649f8b054bf8cddfa6e39dd76
BLAKE2b-256 0ade35aa5e5d0ef7f89256676b6f3d0027793c4f82338efb42caa92e3219767f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page