Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDF File Malformed UTF-8 characters, possibly incorrectly encoded #201

Open
MuhammadAslam945 opened this issue Aug 14, 2024 · 4 comments
Open

Comments

@MuhammadAslam945
Copy link

"message": "Malformed UTF-8 characters, possibly incorrectly encoded",
"exception": "InvalidArgumentException",

$dataReader = new FileDataReader($file);
    //dd($dataReader);
    //$filePath =
    $documents = $dataReader->getDocuments();
    // dd($documents);
    // $documents = new Document($text);
    //($documents);
    $splittedDocuments = DocumentSplitter::splitDocuments($documents, 500);

    return $splittedDocuments;

    $embeddingGenerator = new OpenAI3SmallEmbeddingGenerator($config);
    $embeddedDocuments = $embeddingGenerator->embedText($text);

    return $embeddedDocuments;
    dd($embeddedDocuments);
@MuhammadAslam945
Copy link
Author

{
"message": "Malformed UTF-8 characters, possibly incorrectly encoded",
"exception": "InvalidArgumentException",
"file": "D:\RagLara\vendor\laravel\framework\src\Illuminate\Http\JsonResponse.php",
"line": 90,
"trace": [
{
"file": "D:\RagLara\vendor\symfony\http-foundation\JsonResponse.php",
"line": 49,
"function": "setData",
"class": "Illuminate\Http\JsonResponse",
"type": "->"
},
{
"file": "D:\RagLara\vendor\laravel\framework\src\Illuminate\Http\JsonResponse.php",
"line": 32,
"function": "__construct",
"class": "Symfony\Component\HttpFoundation\JsonResponse",
"type": "->"

@MuhammadAslam945
Copy link
Author

if ($request->hasFile('file')) {
        $file = $request->file->getRealPath();
    } else {
        return 'file not found';
    }
    $dataReader = new FileDataReader($file);

    $documents = $dataReader->getDocuments();

    $splittedDocuments = DocumentSplitter::splitDocuments($documents, 800);

    return $splittedDocuments;
    $embeddingGenerator = new OpenAI3SmallEmbeddingGenerator($config);
    $embeddedDocuments = $embeddingGenerator->embedText($text);

    $memoryVectorStore = new MemoryVectorStore;
    $memoryVectorStore->addDocuments($embeddedDocuments);

    //Once the vectorStore is ready, you can then use the QuestionAnswering class to answer questions
    $qa = new QuestionAnswering(
        $memoryVectorStore,
        $embeddingGenerator,
        new OpenAIChat
    );

    $answer = $qa->answerQuestion('what is the secret of Alice?');

    // control the behavior of the underlying vector store, see VectorStoreBase::similaritySearch
    $answer = $qa->answerQuestion('Where does Alice live?', 2, ['type' => 'city']);

@f-lombardo
Copy link
Contributor

"message": "Malformed UTF-8 characters, possibly incorrectly encoded", "exception": "InvalidArgumentException",

A fix related to wrong encoding in embedding texts has just been integrated. Could you please check if it solves your problem?

@MuhammadAslam945
Copy link
Author

MuhammadAslam945 commented Aug 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants