mirror of
https://github.com/microsoft/graphrag.git
synced 2025-06-26 23:19:58 +00:00
Merge branch 'main' into copilot/fix-1943
This commit is contained in:
commit
4d13011054
34
.semversioner/2.3.0.json
Normal file
34
.semversioner/2.3.0.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"changes": [
|
||||
{
|
||||
"description": "Remove Dynamic Max Retries support. Refactor typer typing in cli interface",
|
||||
"type": "minor"
|
||||
},
|
||||
{
|
||||
"description": "Update fnllm to latest. Update default graphrag configuration",
|
||||
"type": "minor"
|
||||
},
|
||||
{
|
||||
"description": "A few fixes and enhancements for better reuse and flow.",
|
||||
"type": "patch"
|
||||
},
|
||||
{
|
||||
"description": "Add full llm response to LLM PRovider output",
|
||||
"type": "patch"
|
||||
},
|
||||
{
|
||||
"description": "Fix Drift Reduce Response for non streaming calls",
|
||||
"type": "patch"
|
||||
},
|
||||
{
|
||||
"description": "Fix global search prompt to include missing formatting key",
|
||||
"type": "patch"
|
||||
},
|
||||
{
|
||||
"description": "Upgrade pyarrow dependency to >=17.0.0 to fix CVE-2024-52338",
|
||||
"type": "patch"
|
||||
}
|
||||
],
|
||||
"created_at": "2025-05-23T21:02:47+00:00",
|
||||
"version": "2.3.0"
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"type": "minor",
|
||||
"description": "Update fnllm to latest. Update default graphrag configuration"
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"type": "minor",
|
||||
"description": "Remove Dynamic Max Retries support. Refactor typer typing in cli interface"
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"description": "A few fixes and enhancements for better reuse and flow."
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"description": "Upgrade pyarrow dependency to >=17.0.0 to fix CVE-2024-52338"
|
||||
}
|
@ -1,4 +0,0 @@
|
||||
{
|
||||
"type": "patch",
|
||||
"description": "Fix global search prompt to include missing formatting key"
|
||||
}
|
10
CHANGELOG.md
10
CHANGELOG.md
@ -1,6 +1,16 @@
|
||||
# Changelog
|
||||
Note: version releases in the 0.x.y range may introduce breaking changes.
|
||||
|
||||
## 2.3.0
|
||||
|
||||
- minor: Remove Dynamic Max Retries support. Refactor typer typing in cli interface
|
||||
- minor: Update fnllm to latest. Update default graphrag configuration
|
||||
- patch: A few fixes and enhancements for better reuse and flow.
|
||||
- patch: Add full llm response to LLM PRovider output
|
||||
- patch: Fix Drift Reduce Response for non streaming calls
|
||||
- patch: Fix global search prompt to include missing formatting key
|
||||
- patch: Upgrade pyarrow dependency to >=17.0.0 to fix CVE-2024-52338
|
||||
|
||||
## 2.2.1
|
||||
|
||||
- patch: Fix Community Report prompt tuning response
|
||||
|
@ -83,7 +83,10 @@ class OpenAIChatFNLLM:
|
||||
else:
|
||||
response = await self.model(prompt, history=history, **kwargs)
|
||||
return BaseModelResponse(
|
||||
output=BaseModelOutput(content=response.output.content),
|
||||
output=BaseModelOutput(
|
||||
content=response.output.content,
|
||||
full_response=response.output.raw_model.to_dict(),
|
||||
),
|
||||
parsed_response=response.parsed_json,
|
||||
history=response.history,
|
||||
cache_hit=response.cache_hit,
|
||||
@ -282,7 +285,10 @@ class AzureOpenAIChatFNLLM:
|
||||
else:
|
||||
response = await self.model(prompt, history=history, **kwargs)
|
||||
return BaseModelResponse(
|
||||
output=BaseModelOutput(content=response.output.content),
|
||||
output=BaseModelOutput(
|
||||
content=response.output.content,
|
||||
full_response=response.output.raw_model.to_dict(),
|
||||
),
|
||||
parsed_response=response.parsed_json,
|
||||
history=response.history,
|
||||
cache_hit=response.cache_hit,
|
||||
|
@ -18,6 +18,11 @@ class ModelOutput(Protocol):
|
||||
"""Return the textual content of the output."""
|
||||
...
|
||||
|
||||
@property
|
||||
def full_response(self) -> dict[str, Any] | None:
|
||||
"""Return the complete JSON response returned by the model."""
|
||||
...
|
||||
|
||||
|
||||
class ModelResponse(Protocol, Generic[T]):
|
||||
"""Protocol for LLM response."""
|
||||
@ -43,6 +48,10 @@ class BaseModelOutput(BaseModel):
|
||||
|
||||
content: str = Field(..., description="The textual content of the output.")
|
||||
"""The textual content of the output."""
|
||||
full_response: dict[str, Any] | None = Field(
|
||||
None, description="The complete JSON response returned by the LLM provider."
|
||||
)
|
||||
"""The complete JSON response returned by the LLM provider."""
|
||||
|
||||
|
||||
class BaseModelResponse(BaseModel, Generic[T]):
|
||||
|
50
graphrag/language_model/response/base.pyi
Normal file
50
graphrag/language_model/response/base.pyi
Normal file
@ -0,0 +1,50 @@
|
||||
# Copyright (c) 2025 Microsoft Corporation.
|
||||
# Licensed under the MIT License
|
||||
|
||||
from typing import Any, Generic, Protocol, TypeVar
|
||||
|
||||
from pydantic import BaseModel
|
||||
|
||||
_T = TypeVar("_T", bound=BaseModel, covariant=True)
|
||||
|
||||
class ModelOutput(Protocol):
|
||||
@property
|
||||
def content(self) -> str: ...
|
||||
@property
|
||||
def full_response(self) -> dict[str, Any] | None: ...
|
||||
|
||||
class ModelResponse(Protocol, Generic[_T]):
|
||||
@property
|
||||
def output(self) -> ModelOutput: ...
|
||||
@property
|
||||
def parsed_response(self) -> _T | None: ...
|
||||
@property
|
||||
def history(self) -> list[Any]: ...
|
||||
|
||||
class BaseModelOutput(BaseModel):
|
||||
content: str
|
||||
full_response: dict[str, Any] | None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
content: str,
|
||||
full_response: dict[str, Any] | None = None,
|
||||
) -> None: ...
|
||||
|
||||
class BaseModelResponse(BaseModel, Generic[_T]):
|
||||
output: BaseModelOutput
|
||||
parsed_response: _T | None
|
||||
history: list[Any]
|
||||
tool_calls: list[Any]
|
||||
metrics: Any | None
|
||||
cache_hit: bool | None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
output: BaseModelOutput,
|
||||
parsed_response: _T | None = None,
|
||||
history: list[Any] = ..., # default provided by Pydantic
|
||||
tool_calls: list[Any] = ..., # default provided by Pydantic
|
||||
metrics: Any | None = None,
|
||||
cache_hit: bool | None = None,
|
||||
) -> None: ...
|
@ -386,7 +386,7 @@ class DRIFTSearch(BaseSearch[DRIFTSearchContextBuilder]):
|
||||
model_response = await self.model.achat(
|
||||
prompt=query,
|
||||
history=search_messages,
|
||||
model_parameters=llm_kwargs,
|
||||
model_parameters=llm_kwargs.get("model_params", {}),
|
||||
)
|
||||
|
||||
reduced_response = model_response.output.content
|
||||
|
@ -1,7 +1,7 @@
|
||||
[tool.poetry]
|
||||
name = "graphrag"
|
||||
# Maintainers: do not change the version here manually, use ./scripts/release.sh
|
||||
version = "2.2.1"
|
||||
version = "2.3.0"
|
||||
description = "GraphRAG: A graph-based retrieval-augmented generation (RAG) system."
|
||||
authors = [
|
||||
"Alonso Guevara Fernández <alonsog@microsoft.com>",
|
||||
|
@ -33,7 +33,11 @@ async def test_create_custom_chat_model():
|
||||
def chat(
|
||||
self, prompt: str, history: list | None = None, **kwargs: Any
|
||||
) -> ModelResponse:
|
||||
return BaseModelResponse(output=BaseModelOutput(content="content"))
|
||||
return BaseModelResponse(
|
||||
output=BaseModelOutput(
|
||||
content="content", full_response={"key": "value"}
|
||||
)
|
||||
)
|
||||
|
||||
async def achat_stream(
|
||||
self, prompt: str, history: list | None = None, **kwargs: Any
|
||||
@ -49,9 +53,11 @@ async def test_create_custom_chat_model():
|
||||
assert isinstance(model, CustomChatModel)
|
||||
response = await model.achat("prompt")
|
||||
assert response.output.content == "content"
|
||||
assert response.output.full_response is None
|
||||
|
||||
response = model.chat("prompt")
|
||||
assert response.output.content == "content"
|
||||
assert response.output.full_response == {"key": "value"}
|
||||
|
||||
|
||||
async def test_create_custom_embedding_llm():
|
||||
|
Loading…
x
Reference in New Issue
Block a user