incomplete output
andyzhou1982 opened this issue · comments
andyzhou1982 commented
Checked other resources
- I added a very descriptive title to this issue.
- I searched the LangChain documentation with the integrated search.
- I used the GitHub search to find a similar question and didn't find it.
- I am sure that this is a bug in LangChain rather than my code.
- The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
Example Code
llm = Tongyi(model="qwen-max-longcontext")
def load_file(file_path:str):
loader = UnstructuredFileLoader(file_path)
docs = loader.load()
content = docs[0].page_content
return content
def generate(file_path:str):
req_doc = load_file(file_path=file_path)
entities_prompt = PromptTemplate(template=GENERATE_ENTITIES_TEMPLATE,input_variables=["req_doc"],template_format="mustache")
generate_entities_chain = LLMChain(llm=llm, prompt=entities_prompt,output_key="entities")
methods_prompt = PromptTemplate(template=GENERATE_METHODS_TEMPLATE,input_variables=["req_doc","entities"],template_format="mustache")
generate_methods_chain = LLMChain(llm=llm, prompt=methods_prompt,output_key="entitiesWithMethods")
generate_chain = SequentialChain(
chains=[generate_entities_chain,generate_methods_chain],
input_variables=["req_doc"],
memory = ConversationBufferMemory(),
verbose=True
)
response = generate_chain.invoke({"req_doc": req_doc})
print(f"response: {response}")
return response["entitiesWithMethods"]
### Error Message and Stack Trace (if applicable)
```json
{
"name": "Warehouse",
"properties": [
{
"name": "warehouse_id",
"type": "string"
},
{
"name": "warehouse_name",
"type": "string"
}
],
"methods": [
{
"name": "addWarehouse",
"parameters": "warehouseName: string",
"return": "boolean"
},
{
"name": "deleteWarehouseById",
"parameters": "warehouseId: string",
"return": "boolean"
},
{
"name": "updateWarehouse",
"parameters": "warehouseId: string, newName: string",
"return": "boolean"
},
{
"name": "getWarehouseById",
"parameters": "warehouseId: string",
"return": "Warehouse"
},
{
"name": "searchWarehouses",
"parameters": "keyword: string",
"return": "List<Warehouse>"
}
]
},
{
"name": "Product",
"properties": [
{
"name": "product_code",
"type": "string"
},
{
"name": "product_name",
"type": "string"
},
{
"name": "product_model",
"type": "string"
},
{
"name": "product_specification",
"type": "string"
},
{
"name": "manufacturer",
"type": "string"
},
{
"name": "quantity",
"type": "integer"
},
{
"name": "cost_price",
"type": "decimal"
},
{
"name": "market_price",
"type": "decimal"
}
],
"methods": [
{
"name": "addProduct",
"parameters": "productCode: string, productName: string, productModel: string, productSpecification: string, manufacturer: string, costPrice: decimal, marketPrice: decimal",
"return": "boolean"
},
{
"name": "deleteProductById",
"parameters": "productId: string",
"return": "boolean"
},
{
"name": "updateProduct",
"parameters": "productId: string, newProductName: string, newProductModel: string, newProductSpecification: string, newManufacturer: string, newCostPrice: decimal, newMarketPrice: decimal",
"return": "boolean"
},
{
"name": "getProductById",
"parameters": "productId: string",
"return": "Product"
},
{
"name": "searchProducts",
"parameters": "keyword: string",
"return": "List<Product>"
}
]
},
{
"name": "Inventory_Adjustment",
"properties": [
{
"name": "adjustment_id",
"type": "string"
},
{
"name": "product_id",
"type": "string"
},
{
"name": "original_quantity",
"type": "integer",
"description": "原库存数量"
},
{
"name": "adjusted_quantity",
"type": "integer"
},
{
"name": "adjustment_reason",
"type": "string"
},
{
"name": "adjustment_date",
"type": "date"
},
{
"name": "handler",
"type": "string"
}
],
"methods": [
{
"name": "createAdjustment",
"parameters": "productId: string, originalQuantity: integer, adjustedQuantity: integer, adjustmentReason: string, handler: string",
"return": "boolean"
},
{
"name": "deleteInventoryAdjustmentById",
"parameters": "adjustmentId: string",
"return": "boolean"
},
{
"name": "updateInventoryAdjustment",
"parameters": "adjustmentId: string, newAdjustedQuantity: integer, newAdjustmentReason: string",
"return": "boolean"
},
{
"name": "getInventoryAdjustmentById",
"parameters": "adjustmentId: string",
"return": "Inventory_Adjustment"
},
{
"name": "searchInventoryAdjustments",
"parameters": "startDate: date, endDate: date",
"return": "List<Inventory_Adjustment>"
}
]
},
{
"name": "StockTransfer",
"properties": [
{
"name": "transfer_id",
"type": "string"
},
{
"name": "source_warehouse_id",
"type": "string"
},
{
"name": "target_warehouse_id",
"type": "string"
},
{
"name": "product_id",
"type": "string"
},
{
"name": "quantity",
"type": "integer"
},
{
"name": "transfer_date",
"type": "date"
},
{
"name": "handler",
"type": "string"
}
],
"methods": [
{
"name": "createStockTransfer",
"parameters": "sourceWarehouseId: string, targetWarehouseId: string, productId: string, quantity: integer, handler: string",
"return": "boolean"
},
{
"name": "deleteStockTransferById",
"parameters": "transferId: string",
"return": "boolean"
},
{
"name": "updateStockTransfer",
"parameters": "transferId: string, newTargetWarehouseId: string, newQuantity: integer",
"return": "boolean"
},
{
"name": "getStockTransferById",
"parameters": "transferId: string",
"return": "StockTransfer"
},
{
"name": "searchStockTransfers",
"parameters": "startDate: date, endDate: date",
"return": "List<StockTransfer>"
}
]
},
{
"name": "Inventory_Audit",
"properties": [
{
"name": "audit_id",
"type": "string"
},
{
"name": "auditor",
"type": "string"
},
{
"name": "audit_date",
"type": "date"
},
{
"name": "audit_result",
"type": "string"
}
],
"methods": [
{
"name": "conductAudit",
"parameters": "auditor: string",
"return": "boolean"
},
{
"name": "getAuditById",
"parameters": "auditId: string",
"return": "Inventory_Audit"
},
{
"name": "searchAudits",
"parameters": "startDate: date, endDate: date",
"return": "List<Inventory_Audit>"
}
]
},
{
### Description
I want to generate entity objects based on requirement documents,but the output is incomplete,how can i fix it?
### System Info
requirements.txt
langchain==0.1.16
langchain-community==0.0.34
langchain-core==0.1.46
langchain-experimental==0.0.52
langchain-openai==0.1.4
langchain-text-splitters==0.0.1
platform
windows
python version
3.10.14
Mohammad Mohtashim commented
Can you please further elaborate?