ollama - ✅(Solved) Fix Integration [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
ollama/ollama#14750Fetched 2026-04-08 00:32:08
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
labeled ×1

PR fix notes

PR #14644: docs: add Project David to community integrations

Description (problem / solution / changelog)

Project David is an open-source AI orchestration substrate for building, running, and coordinating intelligent agents at scale — think OpenAI's control plane and Assistants API features, fully self-hosted.

It uses Ollama as a first-class model backend, giving engineers who won't trade data sovereignty for convenience a complete stack: open-weight models, owned infrastructure, and production-grade agent orchestration.

Platform tools available out of the box:

ToolDescription
computerContainerised Linux environment connected to the internet
web_searchQuery a search engine and synthesize responses from live web content
deep_researchMulti-hop reasoning and long-horizon synthesis across multiple inference passes
file_searchSearch and retrieve files from accessible vector stores
code_interpreterExecute Python, draft documents, and perform data analysis in a secure sandbox

Ollama handles model serving — Project David handles everything above it. The two projects complement each other directly and share the same audience: engineers who care about ownership and data sovereignty.

Changed files

  • README.md (modified, +1/-0)

Code Example

import json
from dotenv import load_dotenv
from projectdavid import Entity, ToolCallRequestEvent

load_dotenv()

# Universal Function call handler
def get_flight_times(tool_name: str, arguments: dict) -> str:
    return json.dumps({
        "status": "success",
        "departure": arguments.get("departure", "UNK"),
        "arrival": arguments.get("arrival", "UNK"),
        "duration": "4h 30m",
    })

TOOL_REGISTRY = {
    "get_flight_times": get_flight_times,
}

client = Entity()

# 1. Create the Assistant and attach tools
assistant = client.assistants.create_assistant(
    name="Test Assistant",
    model="gpt-oss-120b",
    instructions="You are a helpful AI assistant, your name is Nexa.",
    tools=[{
        "type": "function",
        "function": {
            "name": "get_flight_times",
            "description": "Get flight times",
            "parameters": {
                "type": "object",
                "properties": {
                    "departure": {"type": "string"},
                    "arrival": {"type": "string"},
                },
                "required": ["departure", "arrival"],
            },
        },
    }],
)

thread = client.threads.create_thread()

message = client.messages.create_message(
    thread_id=thread.id,
    role="user",
    content="Please provide the flight times for a trip departing from Tokyo and arriving in Sydney?",
    assistant_id=assistant.id,
)

run = client.runs.create_run(assistant_id=assistant.id, thread_id=thread.id)

# 2. Setup Streaming
stream = client.synchronous_inference_stream
stream.setup(
    thread_id=thread.id,
    assistant_id=assistant.id,
    message_id=message.id,
    run_id=run.id,
)

# 3. Stream events via Ollama and handle tool execution dynamically
for event in stream.stream_events(model="ollama/qwen3:4b"):
    print(f"{event.__class__.__name__:<25} | {json.dumps(event.to_dict())}")
    
    if isinstance(event, ToolCallRequestEvent):
        handler = TOOL_REGISTRY.get(event.tool_name)
        if handler:
            print(f"\n[TOOL CALL] {event.tool_name} → executing...")
            event.execute(handler)
            print("[✓] Result submitted — resuming stream...\n")
        else:
            print(f"\n[!] Unknown tool: '{event.tool_name}'\n")
RAW_BUFFERClick to expand / collapse

Hi Ollama team,

I have developed an Open Source orchestration layer compatible with OpenAI's Assistants API that seamlessly integrates with Ollama.

It provides state management, universal function call handling, and built-in platform tools that give users fast access to code_interpreter, computer, web_search, file_search (RAG), and deep_research. Aside from serving as a general SDK for Ollama, it provides enterprise-grade orchestration, compliance, and logging.

Here is a quick, stripped-down example demonstrating how easy it is to set up an assistant, handle tool calls, and stream inference directly with Ollama:

import json
from dotenv import load_dotenv
from projectdavid import Entity, ToolCallRequestEvent

load_dotenv()

# Universal Function call handler
def get_flight_times(tool_name: str, arguments: dict) -> str:
    return json.dumps({
        "status": "success",
        "departure": arguments.get("departure", "UNK"),
        "arrival": arguments.get("arrival", "UNK"),
        "duration": "4h 30m",
    })

TOOL_REGISTRY = {
    "get_flight_times": get_flight_times,
}

client = Entity()

# 1. Create the Assistant and attach tools
assistant = client.assistants.create_assistant(
    name="Test Assistant",
    model="gpt-oss-120b",
    instructions="You are a helpful AI assistant, your name is Nexa.",
    tools=[{
        "type": "function",
        "function": {
            "name": "get_flight_times",
            "description": "Get flight times",
            "parameters": {
                "type": "object",
                "properties": {
                    "departure": {"type": "string"},
                    "arrival": {"type": "string"},
                },
                "required": ["departure", "arrival"],
            },
        },
    }],
)

thread = client.threads.create_thread()

message = client.messages.create_message(
    thread_id=thread.id,
    role="user",
    content="Please provide the flight times for a trip departing from Tokyo and arriving in Sydney?",
    assistant_id=assistant.id,
)

run = client.runs.create_run(assistant_id=assistant.id, thread_id=thread.id)

# 2. Setup Streaming
stream = client.synchronous_inference_stream
stream.setup(
    thread_id=thread.id,
    assistant_id=assistant.id,
    message_id=message.id,
    run_id=run.id,
)

# 3. Stream events via Ollama and handle tool execution dynamically
for event in stream.stream_events(model="ollama/qwen3:4b"):
    print(f"{event.__class__.__name__:<25} | {json.dumps(event.to_dict())}")
    
    if isinstance(event, ToolCallRequestEvent):
        handler = TOOL_REGISTRY.get(event.tool_name)
        if handler:
            print(f"\n[TOOL CALL] {event.tool_name} → executing...")
            event.execute(handler)
            print("[✓] Result submitted — resuming stream...\n")
        else:
            print(f"\n[!] Unknown tool: '{event.tool_name}'\n")

I have raised PR https://github.com/ollama/ollama/pull/14644 to be featured in the integrations section of your README. As per the CONTRIBUTING.md, I wanted to open this issue to provide context and start a discussion. I am here to address any questions or concerns you might have. Thank you for your time and for the amazing work on Ollama! Best, Francis

extent analysis

Fix Plan

To integrate the Open Source orchestration layer with Ollama, we need to modify the code to handle tool calls and streaming inference.

Here are the steps:

  • Update the TOOL_REGISTRY to include all available tools.
  • Implement a universal function call handler to execute tool calls dynamically.
  • Set up streaming inference using the synchronous_inference_stream.
  • Handle tool execution and streaming events.

Example Code

# Update TOOL_REGISTRY to include all available tools
TOOL_REGISTRY = {
    "get_flight_times": get_flight_times,
    "code_interpreter": code_interpreter_handler,
    "computer": computer_handler,
    "web_search": web_search_handler,
    "file_search": file_search_handler,
    "deep_research": deep_research_handler,
}

# Implement a universal function call handler
def universal_handler(tool_name: str, arguments: dict) -> str:
    handler = TOOL_REGISTRY.get(tool_name)
    if handler:
        return handler(tool_name, arguments)
    else:
        return json.dumps({"status": "error", "message": "Unknown tool"})

# Set up streaming inference
stream = client.synchronous_inference_stream
stream.setup(
    thread_id=thread.id,
    assistant_id=assistant.id,
    message_id=message.id,
    run_id=run.id,
)

# Handle tool execution and streaming events
for event in stream.stream_events(model="ollama/qwen3:4b"):
    print(f"{event.__class__.__name__:<25} | {json.dumps(event.to_dict())}")
    
    if isinstance(event, ToolCallRequestEvent):
        print(f"\n[TOOL CALL] {event.tool_name} → executing...")
        event.execute(universal_handler)
        print("[✓] Result submitted — resuming stream...\n")

Verification

To verify that the fix worked, run the updated code and check that:

  • Tool calls are executed correctly.
  • Streaming inference is set up and handling events as expected.
  • The universal_handler function is called for each tool execution.

Extra Tips

  • Make sure to update the TOOL_REGISTRY with all available tools.
  • Implement error handling for unknown tools and other potential errors.
  • Test the code thoroughly to ensure that it works as expected.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING