Closed thunderbolt-fire closed 3 months ago
你好!
nano-graphrag
主要的目的是为了保持一个简单的graphrag实现 所以各种组件都只支持最主流简易的一个方法,但是组件都是可以替换的。
我添加了一个使用deepseek作为nano-graphrag
的大模型的例子,希望可以帮助到你:
你好!
nano-graphrag
主要的目的是为了保持一个简单的graphrag实现 所以各种组件都只支持最主流简易的一个方法,但是组件都是可以替换的。 我添加了一个使用deepseek作为nano-graphrag
的大模型的例子,希望可以帮助到你:
谢谢,但是我测试之后发现存在问题。
$ python examples/using_deepseek_as_llm.py
Traceback (most recent call last):
File "/workspaces/nano-graphrag/examples/using_deepseek_as_llm.py", line 4, in <module>
from nano_graphrag import GraphRAG, QueryParam
File "/workspaces/nano-graphrag/nano_graphrag/__init__.py", line 1, in <module>
from .graphrag import GraphRAG, QueryParam
File "/workspaces/nano-graphrag/nano_graphrag/graphrag.py", line 11, in <module>
from ._op import (
File "/workspaces/nano-graphrag/nano_graphrag/_op.py", line 32, in <module>
openai_async_client = AsyncOpenAI()
File "/home/codespace/.local/lib/python3.10/site-packages/openai/_client.py", line 319, in __init__
raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
正确设置了deepseek的api后无法运行,于是我把_op.py文件中的#openai_async_client = AsyncOpenAI()
注释掉后,开始可以运行,但是运行一段时间后仍然报错。
$ python examples/using_deepseek_as_llm.py
INFO:nano-graphrag:Creating working directory ./nano_graphrag_cache_deepseek_TEST
INFO:nano-graphrag:Load KV full_docs with 0 data
INFO:nano-graphrag:Load KV text_chunks with 0 data
INFO:nano-graphrag:Load KV llm_response_cache with 0 data
INFO:nano-graphrag:Load KV community_reports with 0 data
DEBUG:pymilvus.milvus_client.milvus_client:Created new connection using: f279a800c3894599af88f1f2e763f719
DEBUG:pymilvus.milvus_client.milvus_client:Successfully created collection: entities
DEBUG:pymilvus.milvus_client.milvus_client:Successfully created an index on collection: entities
INFO:nano-graphrag:[New Docs] inserting 1 docs
INFO:nano-graphrag:[New Chunks] inserting 42 chunks
INFO:nano-graphrag:[Entity Extraction]...
INFO:nano-graphrag:Inserting 418 vectors to entities
Traceback (most recent call last):
File "/workspaces/nano-graphrag/examples/using_deepseek_as_llm.py", line 97, in <module>
remove_if_exist(f"{WORKING_DIR}/milvus_lite.db")
File "/workspaces/nano-graphrag/examples/using_deepseek_as_llm.py", line 90, in insert
from time import time
File "/workspaces/nano-graphrag/nano_graphrag/graphrag.py", line 145, in insert
return asyncio.run(self.ainsert(string_or_strings))
File "/usr/local/python/3.10.13/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/usr/local/python/3.10.13/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/workspaces/nano-graphrag/nano_graphrag/graphrag.py", line 224, in ainsert
self.chunk_entity_relation_graph = await extract_entities(
File "/workspaces/nano-graphrag/nano_graphrag/_op.py", line 335, in extract_entities
await entity_vdb.upsert(data_for_vdb)
File "/workspaces/nano-graphrag/nano_graphrag/_storage.py", line 105, in upsert
embeddings_list = await asyncio.gather(
File "/workspaces/nano-graphrag/nano_graphrag/_utils.py", line 134, in wait_func
result = await func(*args, **kwargs)
File "/workspaces/nano-graphrag/nano_graphrag/_utils.py", line 117, in __call__
return await self.func(*args, **kwargs)
File "/workspaces/nano-graphrag/nano_graphrag/_llm.py", line 61, in openai_embedding
openai_async_client = AsyncOpenAI()
File "/home/codespace/.local/lib/python3.10/site-packages/openai/_client.py", line 319, in __init__
raise OpenAIError(
openai.OpenAIError: The api_key client option must be set either by passing api_key to the client or by setting the OPENAI_API_KEY environment variable
你好 因为这个是embedding模型服务 不是大语言模型的服务。
nano-graphrag
里需要生成embedding来进行检索。 embedding函数也是可以替换的
你好 因为这个是embedding模型服务 不是大语言模型的服务。
nano-graphrag
里需要生成embedding来进行检索。 embedding函数也是可以替换的
能不能用一个样例说明一下
INFO:nano-graphrag:Inserting 135 vectors to entities
Traceback (most recent call last):
File "/mnt/f/github/nano-graphrag/examples/using_deepseek_as_llm.py", line 99, in
@thunderbolt-fire @zhaofangtao 你好 你们可以参考这个例子替换自己想要使用的embedding 模型: https://github.com/gusye1234/nano-graphrag/blob/main/examples/using_local_embedding_model.py
如何使用其他在线模型,例如qwen , deepseek等