{"id":19947370,"url":"https://github.com/firstbatchxyz/dria-python-client","last_synced_at":"2025-05-03T17:33:48.473Z","repository":{"id":221488285,"uuid":"744858601","full_name":"firstbatchxyz/dria-python-client","owner":"firstbatchxyz","description":"Permissionless access to AI knowledge as a public good","archived":false,"fork":false,"pushed_at":"2024-04-21T16:07:44.000Z","size":94,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-21T21:16:30.912Z","etag":null,"topics":["firstbatch","rag","vector-search"],"latest_commit_sha":null,"homepage":"https://dria.co/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/firstbatchxyz.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}},"created_at":"2024-01-18T06:33:20.000Z","updated_at":"2024-04-21T16:07:47.000Z","dependencies_parsed_at":"2024-04-21T18:05:46.051Z","dependency_job_id":"8121ab03-f2ca-47ef-8016-d6abbd10bd2a","html_url":"https://github.com/firstbatchxyz/dria-python-client","commit_stats":null,"previous_names":["firstbatchxyz/dria-python-client"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-python-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-python-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-python-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstbatchxyz%2Fdria-python-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firstbatchxyz","download_url":"https://codeload.github.com/firstbatchxyz/dria-python-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224370253,"owners_count":17299968,"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":["firstbatch","rag","vector-search"],"created_at":"2024-11-13T00:35:47.828Z","updated_at":"2024-11-13T00:35:48.465Z","avatar_url":"https://github.com/firstbatchxyz.png","language":"Python","readme":"\u003cp align=\"center\"\u003e\n  \u003c!-- \u003cimg src=\"logo.svg\" alt=\"logo\" width=\"142\"\u003e --\u003e\n  \u003cimg src=\"./logo.svg\" alt=\"logo\" width=\"142\"\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ch1 align=\"center\"\u003e\n    Dria\n  \u003c/h1\u003e\n  \u003cp align=\"center\"\u003e\n    \u003ci\u003eDria Python client.\u003c/i\u003e\n  \u003c/p\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://pypi.org/project/dria\" target=\"_blank\"\u003e\n        \u003cimg alt=\"PyPI\" src=\"https://badge.fury.io/py/dria.svg\"\u003e\n    \u003c/a\u003e\n\u003c/p\u003e\n\n## Description\nThe **Dria Python Client** is a powerful Python library that seamlessly integrates with the Dria API, providing a convenient interface to harness the capabilities of Dria's vector search and retrieval services. Dria is a cutting-edge platform designed to streamline your AI-powered search and data retrieval tasks, and this client empowers Python developers to leverage its full potential.\n\n## Features\n- Knowledge Base Management: Create and manage knowledge bases effortlessly.\n- Data Upload with Text: Choose your embedding model and upload data with text.\n- Vector Search: Perform vector-based searches and retrieve relevant results.\n- Multi Region Support: Access Dria's services from multiple regions.\n- Text-based Search: Perform text-based searches and retrieve relevant results.\n- Query with Vectors: Utilize vector queries to obtain contextually accurate responses.\n- Data Fetching: Fetch specific data entries by their IDs.\n- Batch Data Insertion: Efficiently insert data in bulk into Dria's knowledge base.\n- Model Variety: Support for a range of text embedding models, including OpenAI's Text Embeddings and Jina's Embeddings V2.\n\n## Installation\nTo install the **Dria Python Client**, you can use pip:\n\n```bash\npip install dria\n```\n\n### Accessing the Dria API\nTo use the Dria Python Client, you need to have an API key. You can obtain your API key by signing up on the [Dria](https://dria.co/) and also you can get 500 free credits for upload data and use the API.\n\n## Supported Embedding Models\n\nThe Dria Python Client supports a variety of text embedding models, including:\n\n- OpenAI's Text Embeddings-2 Ada (text-embedding-ada-002)\n- OpenAI's Text Embedding-3 Small (text-embedding-3-large)\n- OpenAI's Text Embedding-3 Large (text-embedding-ada-002)\n- Jina's Embeddings V2 Base EN (jina-embeddings-v2-base-en)\n- Jina's Embeddings V2 Small EN (jina-embeddings-v2-small-en)\n- BAAI/bge-large-en-1.5\n- BAAI/bge-base-en-1.5\n\n## Custom Embedding Models\n\nIn addition to the pre-defined text embedding models, the Dria Python Client also allows you to use custom embedding models. Custom embedding models can be useful when you have specific requirements or when you want to fine-tune your text embeddings for your knowledge base.\n\nPlease note that when using custom embedding models, you won't be able to perform text-based searches through the Dria API or UI. You can only perform vector-based queries using your custom embeddings.\n\n\n## Usage\n### Querying the Existing Knowledge Base\n```python\nfrom dria import Dria\n\n# Initialize the DriaIndex instance with your API key and knowledge contract ID\ndria_index = Dria(api_key=\"\u003cYOUR_API_KEY\u003e\", contract_id=\"\u003cKNOWLEDGE_CONTRACT_ID\u003e\")\n\n# Perform a text-based search\nresults = dria_index.search(\"What is the capital of France?\", top_n=10)\nprint(results)\n\n# Perform a vector-based query\nvector_query_results = dria_index.query([0.1, 0.2, 0.3], top_n=10)\nprint(vector_query_results)\n\n# Fetch data for specific IDs\nfetched_data = dria_index.fetch([1, 2, 3])\nprint(fetched_data)\n\n\n```\n\n### Create New Knowledge Base\n\n#### Using Pre-defined Embedding Models\n```python\nfrom dria import Dria, Models\n\n# Initialize the Dria instance with your API key\ndria_index = Dria(api_key=\"\u003cYOUR_API_KEY\u003e\")\n\n# Create a new knowledge base\ncontract_id = dria_index.create(\n    name=\"France's AI Development\",\n    embedding=Models.jina_embeddings_v2_base_en,\n    category=\"Artificial Intelligence\",\n    description=\"Explore the growth and contributions of France in the field of Artificial Intelligence.\"\n)\n\nprint(contract_id)\n\n```\n#### Using Custom Embedding Models\n```python\nfrom dria import Dria\n\n# Initialize the Dria instance with your API key\ndria_index = Dria(api_key=\"\u003cYOUR_API_KEY\u003e\")\n\n# Create a new knowledge base\ncontract_id = dria_index.create(\n    name=\"France's AI Development\",\n    embedding=\"intfloat/e5-mistral-7b-instruct\",\n    category=\"Artificial Intelligence\",\n    description=\"Explore the growth and contributions of France in the field of Artificial Intelligence.\"\n)\n\nprint(contract_id)\n\n```\n## Usage Example\n\n### Create a new knowledge base and insert data\n```python\nfrom dria import Dria, Models\n\n# Initialize the Dria instance with your API key\ndria_index = Dria(api_key=\"\u003cYOUR_API_KEY\u003e\")\n\n# Create a new knowledge base\ncontract_id = dria_index.create(\n    name=\"France's AI Development\",\n    embedding=Models.jina_embeddings_v2_base_en,\n    category=\"Artificial Intelligence\",\n    description=\"Explore the growth and contributions of France in the field of Artificial Intelligence.\"\n)\n\n# Insert data into the knowledge base\ndata = [\n    {\n        \"text\": \"The Rise of AI in France\",\n        \"metadata\": {\n            \"author\": \"John Doe\",\n            \"date\": \"2022-01-01\",\n            \"source\": \"AI Magazine\"\n        }\n    },\n    {\n        \"text\": \"France's AI Research and Development\",\n        \"metadata\": {\n            \"author\": \"Jane Smith\",\n            \"date\": \"2022-01-15\",\n            \"source\": \"Tech News\"\n        }\n    }]\nresponse = dria_index.insert_text(data)\nprint(response)\n\nsearch_results = dria_index.search(\"AI in France\", top_n=1, level=0)\n\n```\n### Query to latest uploaded knowledge base\n```python\nfrom dria import Dria\n\n\ndria_index = Dria(api_key=\"\u003cYOUR API KEY\u003e\")\n\n# Get the list of knowledge bases\nknowledges = dria_index.list()\n\n# Set the contract ID\ndria_index.set_contract(knowledges[-1][\"contract_id\"])\n\n# Insert a new knowledge\ndria_index.insert_text([{\"text\": \"Testing latest knowledge...\", \"metadata\": {\"name\": \"Test\"}}])\n\n# Search for the knowledge\nprint(dria_index.search(\"Testing latest knowledge...\", top_n=1, rerank=True))\n```\nLet's try with existing knowledge base. We will use the [The Library of Alexandria](https://dria.co/knowledge/DA9F3YqTRrYEXCFhzaFgOW6jZ0NGn3PK9Q6DjuDHN0E) for this example.\n```python\nfrom dria import Dria\n\ndria_index = Dria(api_key=\"\u003cYOUR_API_KEY\u003e\",\n                       contract_id=\"DA9F3YqTRrYEXCFhzaFgOW6jZ0NGn3PK9Q6DjuDHN0E\")\n\nprint(dria_index.search(\"Who found the first library catalog in the history?\", top_n=10, rerank=True))\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstbatchxyz%2Fdria-python-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstbatchxyz%2Fdria-python-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstbatchxyz%2Fdria-python-client/lists"}