{"id":15785179,"url":"https://github.com/awaescher/oef","last_synced_at":"2025-05-13T01:27:55.593Z","repository":{"id":249948229,"uuid":"833034185","full_name":"awaescher/oef","owner":"awaescher","description":"Ollama Embeddings Forwarder","archived":false,"fork":false,"pushed_at":"2024-07-24T14:13:24.000Z","size":101,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-16T23:53:16.374Z","etag":null,"topics":["embeddings","graphrag","ollama","openai","rag"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/awaescher.png","metadata":{"files":{"readme":"ReadMe.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-24T08:19:02.000Z","updated_at":"2024-10-01T06:34:38.000Z","dependencies_parsed_at":"2024-10-04T20:21:28.540Z","dependency_job_id":null,"html_url":"https://github.com/awaescher/oef","commit_stats":null,"previous_names":["awaescher/poe","awaescher/oef"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2Foef","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2Foef/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2Foef/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/awaescher%2Foef/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/awaescher","download_url":"https://codeload.github.com/awaescher/oef/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234558813,"owners_count":18852284,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["embeddings","graphrag","ollama","openai","rag"],"created_at":"2024-10-04T20:21:24.255Z","updated_at":"2025-01-18T20:06:25.439Z","avatar_url":"https://github.com/awaescher.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"oef is a tiny dotnet web api that can receive GraphRAG embedding requests and forward them to an Ollama instance.\n\n## Why?\n\nThis is necessary because GraphRAG expects an OpenAI compatible api that is very close to but not equal to the embedding api offered by Ollama.\n\nRight now (July 2024) it is not possible to use Ollama embeddings within GraphRAG like this \n\n```yaml\n# settings.yaml\n\nllm:\n  api_key: ollama\n  type: openai_chat\n  model: llama3.1:8b\n  api_base: http://your-ollama-host:11434/v1                    # \u003c-- /v1 has to be added for Ollama's OpenAI compatibility mode\n  ...\n\nembeddings:\n  llm:\n    api_key: ollama\n    type: openai_embedding\n    model: Losspost/stella_en_1.5b_v5:latest\n    api_base: http://your-ollama-host:11434/v1                  # \u003c-- Ollama is not supported here\n\n```\n\nUsing Ollama for embeddings usually leads to this error:\n\u003e datashaper.workflow.workflow ERROR Error executing verb \"cluster_graph\" in create_base_entity_graph: Columns must be same length as key\n \n```batch\ndatashaper.workflow.workflow INFO executing verb summarize_descriptions\ngraphrag.index.emit.parquet_table_emitter INFO emitting parquet table create_summarized_entities.parquet\ngraphrag.index.run INFO Running workflow: create_base_entity_graph...\ngraphrag.index.run INFO dependencies for create_base_entity_graph: ['create_summarized_entities']\ngraphrag.index.run INFO read table from storage: create_summarized_entities.parquet\ndatashaper.workflow.workflow INFO executing verb cluster_graph\ngraphrag.index.verbs.graph.clustering.cluster_graph WARNING Graph has no nodes\ndatashaper.workflow.workflow ERROR Error executing verb \"cluster_graph\" in create_base_entity_graph: Columns must be same length as key\nTraceback (most recent call last):\n  File \"/usr/local/lib/python3.11/site-packages/datashaper/workflow/workflow.py\", line 410, in _execute_verb\n    result = node.verb.func(**verb_args)\n             ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/site-packages/graphrag/index/verbs/graph/clustering/cluster_graph.py\", line 102, in cluster_graph\n    output_df[[level_to, to]] = pd.DataFrame(\n    ~~~~~~~~~^^^^^^^^^^^^^^^^\n  File \"/usr/local/lib/python3.11/site-packages/pandas/core/frame.py\", line 4299, in __setitem__\n    self._setitem_array(key, value)\n  File \"/usr/local/lib/python3.11/site-packages/pandas/core/frame.py\", line 4341, in _setitem_array\n    check_key_length(self.columns, key, value)\n  File \"/usr/local/lib/python3.11/site-packages/pandas/core/indexers/utils.py\", line 390, in check_key_length\n    raise ValueError(\"Columns must be same length as key\")\nValueError: Columns must be same length as key\n```\n\n## How?\n\n### Clone and run oef\n\nClone this repository and run the following command:\n\n```bash\ndotnet run --ollamaurl http://your-ollama-host:11434\n```\n\nThis will start oef which will listen on the defined (or default) port and forward calls to `/v1/embeddings` to the defined Ollama url and translate to the expected json formats in both directions.\n\n![Console](doc/Console.jpg)\n\n### Use oef in settings.yml\n\nIn the `settings.yml` shown above, use the oef endpoint url instead of the Ollama url:\n\n```yaml\n# settings.yaml\n\nllm:\n  api_key: ollama\n  type: openai_chat\n  model: llama3.1:8b\n  api_base: http://your-ollama-host:11434/v1\n  ...\n\nembeddings:\n  llm:\n    api_key: ollama\n    type: openai_embedding\n    model: Losspost/stella_en_1.5b_v5:latest\n    api_base: http://your-oef-host:11435                    # \u003c-- this line needs to be changed\n```\n\nFrom now on, GraphRAG will ask your oef host for the embeddings, which forwards the request to Ollama.\n\n### Settings\n\nThe following settings can be defined when running oef:\n\n|Setting|Command line argument|Environment variable|Default value|\n|-|-|-|-|\n|Port|--port|PORT|11435|\n|Ollama Url|--ollamaurl|OLLAMAURL|- (mandatory)|\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawaescher%2Foef","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fawaescher%2Foef","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fawaescher%2Foef/lists"}