upstage: Upstage Groundedness Check parameter update (#20914)

* Groundedness Check takes `str` or `list[Document]` as input.

* Deprecate `GroundednessCheck` due to its naming.
* Added `UpstageGroundednessCheck`. 

* Hotfix for Groundedness Check parameter. 
  The name `query` was misleading and it should be `answer` instead.

---------

Co-authored-by: Erick Friis <erick@langchain.dev>
This commit is contained in:
Sean
2024-04-26 10:34:05 -07:00
committed by GitHub
parent 84b8e67c9c
commit e1c2e2fdfa
8 changed files with 101 additions and 69 deletions

View File

@@ -52,7 +52,7 @@
"| --- | --- | --- | --- |\n",
"| Chat | Build assistants using Solar Mini Chat | `from langchain_upstage import ChatUpstage` | [Go](../../chat/upstage) |\n",
"| Text Embedding | Embed strings to vectors | `from langchain_upstage import UpstageEmbeddings` | [Go](../../text_embedding/upstage) |\n",
"| Groundedness Check | Verify groundedness of assistant's response | `from langchain_upstage import GroundednessCheck` | [Go](../../tools/upstage_groundedness_check) |\n",
"| Groundedness Check | Verify groundedness of assistant's response | `from langchain_upstage import UpstageGroundednessCheck` | [Go](../../tools/upstage_groundedness_check) |\n",
"| Layout Analysis | Serialize documents with tables and figures | `from langchain_upstage import UpstageLayoutAnalysisLoader` | [Go](../../document_loaders/upstage) |\n",
"\n",
"See [documentations](https://developers.upstage.ai/) for more details about the features."
@@ -145,15 +145,15 @@
},
"outputs": [],
"source": [
"from langchain_upstage import GroundednessCheck\n",
"from langchain_upstage import UpstageGroundednessCheck\n",
"\n",
"groundedness_check = GroundednessCheck()\n",
"groundedness_check = UpstageGroundednessCheck()\n",
"\n",
"request_input = {\n",
" \"context\": \"Mauna Kea is an inactive volcano on the island of Hawaii. Its peak is 4,207.3 m above sea level, making it the highest point in Hawaii and second-highest peak of an island on Earth.\",\n",
" \"query\": \"Mauna Kea is 5,207.3 meters tall.\",\n",
" \"answer\": \"Mauna Kea is 5,207.3 meters tall.\",\n",
"}\n",
"response = groundedness_check.run(request_input)\n",
"response = groundedness_check.invoke(request_input)\n",
"print(response)"
]
},

View File

@@ -48,7 +48,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "a83d4da0",
"metadata": {},
"outputs": [],
@@ -65,21 +65,21 @@
"source": [
"## Usage\n",
"\n",
"Initialize `GroundednessCheck` class."
"Initialize `UpstageGroundednessCheck` class."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "b7373380c01cefbe",
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from langchain_upstage import GroundednessCheck\n",
"from langchain_upstage import UpstageGroundednessCheck\n",
"\n",
"groundedness_check = GroundednessCheck()"
"groundedness_check = UpstageGroundednessCheck()"
]
},
{
@@ -92,38 +92,22 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "1e0115e3b511f57",
"metadata": {
"collapsed": false,
"is_executing": true
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"content='notGrounded' response_metadata={'token_usage': {'completion_tokens': 6, 'prompt_tokens': 198, 'total_tokens': 204}, 'model_name': 'solar-1-mini-answer-verification', 'system_fingerprint': '', 'finish_reason': 'stop', 'logprobs': None} id='run-ce7b5787-2ed0-4a68-9de4-c0e91a824147-0'\n"
]
}
],
"outputs": [],
"source": [
"request_input = {\n",
" \"context\": \"Mauna Kea is an inactive volcano on the island of Hawai'i. Its peak is 4,207.3 m above sea level, making it the highest point in Hawaii and second-highest peak of an island on Earth.\",\n",
" \"query\": \"Mauna Kea is 5,207.3 meters tall.\",\n",
" \"answer\": \"Mauna Kea is 5,207.3 meters tall.\",\n",
"}\n",
"\n",
"response = groundedness_check.run(request_input)\n",
"response = groundedness_check.invoke(request_input)\n",
"print(response)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "054b5031",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {