finic-ai / doctran

MIT License
479 stars 42 forks source link

A compatibility issue #22

Open xieleihan opened 2 months ago

xieleihan commented 2 months ago

Hi, I'm developing langchain and I've found that the latest version of doctran has compatibility issues with pydantic. ipynb keeps prompting ModuleNotFoundError. No module named 'pydantic._internal._validators'

LiuJiPeng20 commented 1 week ago

Hi, I'm developing langchain and I've found that the latest version of doctran has compatibility issues with pydantic. ipynb keeps prompting ModuleNotFoundError. No module named 'pydantic._internal._validators' I'm developing langchain,too。Have you solved it?

xieleihan commented 6 days ago

Of course, I found that the doctran module only supports OpenAI's API, so you may need to use a compatible writing method. I'll post my implementation method here, I hope it will be helpful to you.

import os

from dotenv import find_dotenv, load_dotenv
load_dotenv(find_dotenv())
api_key = os.getenv("DASHSCOPE_API_KEY")

with open('./letter.txt', encoding='utf-8') as f:
    content = f.read()

from langchain.llms import Tongyi
llm = Tongyi(
    model="Qwen", 
    temperature=0, 
    dashscope_api_key=api_key
)

prompt = f"Please translate the following text into Chinese: {content}"

result = llm(prompt)
print(result)