Qwen-vl API request error

Abierto
#73 8 comentarios 0 reacciones 1 asignado Ver en GitHub

Los mantenedores suelen responder en 1 día

@vyokky ya está trabajando en esto.

Desde el 10/5/2024.

Evaluación

Este issue todavía no se ha evaluado.

Descripción

Hey MS UFO team,

Thanks for your excellent work and recent updates for supporting Qwen API.
I'm testing the code on my win11 using the Qwen-vl-plus api, with outlook activated and fully maximized on my desktop in order to be taken a screenshotbut, but constantly receiving the 'Error making API request' issue.
After debugging, I found that although I can receive text response from Qwen-vl-plus, the content doesn't contain 'Observation' part (according to line86-92 of script 'ufo\llm\qwen.py' and the example in 'ufo\app_agent_example.yaml' ), thus raising an exception.
Could you please help identify how to fix the problem? Thanks in advance!
My input and output details are as follows:

(```
UFO) PS D:\Projects\GithubProjects\UFO-v0.1.1> python -m ufo --task 'write email'

Welcome to use UFO🛸, A UI-focused Agent for Windows OS Interaction.


| | | || | / _
| | | || |
| | | |
| |
| || | | || |
_
/ |_| __/

Please enter your request to be completed🛸:
My name is Zac. Please send a email to [email protected] to thanks his contribution on the open source.
Round 1, Step 1: Selecting an application.
Error making API request: To send an email via code, you can use various libraries such as smtplib in Python or JavaMail API in Java.

Here's how you could do it using these tools:

Python:

import smtplib

# Set up your credentials and message content here
sender_email = '[email protected]'
receiver_email = '[email protected]'

message_content = """\
Subject: Thanks for contributing!

Dear Jack,

Thank you very much for your valuable contributions to our open-source project! We appreciate your hard work and dedication.

Best regards,
[Your Name]"""

# Establish connection with SMTP server
with smtplib.SMTP('smtp.example.com', 587) as smtp_server:
    # Start TLS encryption if available
    smtp_server.starttls()

    # Login with your credentials
    smtp_server.login(sender_email, 'password')

    # Send mail
    smtp_server.sendmail(
        sender_email,
        receiver_email,
        message_content.encode()
    )

Java:

import com.sun.mail.smtp.SMTPTransport;
import javax.activation.DataHandler;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

// ...

try {
    // Create session object
    Session session = Session.getDefaultInstance(props);

    // Get address of recipient from command line arguments
    String dest = args[0];

    try {
        InternetAddress internetDest =
            new InternetAddress(dest);
        Message msg = new MimeMessage(session);
        msg.setFrom(new InternetAddress("[email protected]"));
        msg.addRecipient(Message.RecipientType.TO, internetDest);
        msg.setSubject("Thanks for contributing!");
        msg.setText("Dear Jack,\n\n" +
                "Thank you very much for your valuable contributions to our open-source project!\nWe appreciate your hard work and dedication.\n\n" +
                "Best regards," + Environment.NewLine +
                "[Your Name]");
        Transport transport = session.getTransport();
        transport.connect(); // Connects to host specified by properties above
        transport.sendMessage(msg, msg.getAllRecipients());
        System.out.println("Email sent successfully.");
    } catch (MessagingException e) {
        throw new RuntimeException(e);
    }
} finally { ... }

Please replace '[email protected]', ['your-name'] and 'password' with appropriate values before running this script. Also note that sending emails through plain text might not be secure depending on the email service provider. For more security-conscious applications, consider switching to encrypted protocols like SSL/TLS or even HTTPS.
{"status_code": 200, "request_id": "9ff2692f-705c-9724-aba7-304117b95ffc", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": [{"text": "To send an email via code, you can use various libraries such as smtplib in Python or JavaMail API in Java.\n\nHere's how you could do it using these tools:\n\nPython:\npython\nimport smtplib\n\n# Set up your credentials and message content here\nsender_email = '[email protected]'\nreceiver_email = '[email protected]'\n\nmessage_content = \"\"\"\\\nSubject: Thanks for contributing!\n\nDear Jack,\n\nThank you very much for your valuable contributions to our open-source project! We appreciate your hard work and dedication.\n\nBest regards,\n[Your Name]\"\"\"\n\n# Establish connection with SMTP server\nwith smtplib.SMTP('smtp.example.com', 587) as smtp_server:\n # Start TLS encryption if available\n smtp_server.starttls()\n\n # Login with your credentials\n smtp_server.login(sender_email, 'password')\n\n # Send mail\n smtp_server.sendmail(\n sender_email,\n receiver_email,\n message_content.encode()\n )\n\n\nJava:\njava\nimport com.sun.mail.smtp.SMTPTransport;\nimport javax.activation.DataHandler;\nimport javax.mail.Message;\nimport javax.mail.MessagingException;\nimport javax.mail.Session;\nimport javax.mail.Transport;\nimport javax.mail.internet.AddressException;\nimport javax.mail.internet.InternetAddress;\nimport javax.mail.internet.MimeMessage;\n\n// ...\n\ntry {\n // Create session object\n Session session = Session.getDefaultInstance(props);\n\n // Get address of recipient from command line arguments\n String dest = args[0];\n\n try {\n InternetAddress internetDest =\n new InternetAddress(dest);\n Message msg = new MimeMessage(session);\n msg.setFrom(new InternetAddress(\"[email protected]\"));\n msg.addRecipient(Message.RecipientType.TO, internetDest);\n msg.setSubject(\"Thanks for contributing!\");\n msg.setText(\"Dear Jack,\\n\\n\" +\n \"Thank you very much for your valuable contributions to our open-source project!\\nWe appreciate your hard work and dedication.\\n\\n\" +\n \"Best regards,\" + Environment.NewLine +\n \"[Your Name]\");\n Transport transport = session.getTransport();\n transport.connect(); // Connects to host specified by properties above\n transport.sendMessage(msg, msg.getAllRecipients());\n System.out.println(\"Email sent successfully.\");\n } catch (MessagingException e) {\n throw new RuntimeException(e); \n }\n} finally { ... }\n\nPlease replace '[email protected]', ['your-name'] and 'password' with appropriate values before running this script. Also note that sending emails through plain text might not be secure depending on the email service provider. For more security-conscious applications, consider switching to encrypted protocols like SSL/TLS or even HTTPS."}]}}]}, "usage": {"input_tokens": 1241, "output_tokens": 552, "image_tokens": 180}}
Error making API request: To send an email via code, you can use various libraries such as smtplib and email. Here's an example of how you might do this in Python:

import smtplib

# Set up the sender and recipient
sender = '[email protected]'
recipient = '[email protected]'

# Compose the message body
message_body = """
    Subject: Thanks for your contribution!

    Hi Jack,

    Thank you very much for contributing to our open-source project! We really appreciate your help.

    Best regards,
    Zac"""

# Create a secure SSL connection using port 465
with smtplib.SMTP_SSL('smtp.outlook.com', 465) as server:

    # Send the email with the composed message
    server.login(sender, 'your_password')
    server.sendmail(
        sender,
        recipient,
        message_body
    )

Note that you will need to replace '[email protected]', 'your_password', and other placeholders with your actual email address and password. Also be sure to import any necessary modules or dependencies at the top of your script if they're not already imported.
{"status_code": 200, "request_id": "12b3347f-2964-91e0-985a-d348867b4d3f", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": [{"text": "To send an email via code, you can use various libraries such as smtplib and email. Here's an example of how you might do this in Python:\npython\nimport smtplib\n\n# Set up the sender and recipient\nsender = '[email protected]'\nrecipient = '[email protected]'\n\n# Compose the message body\nmessage_body = \"\"\"\n Subject: Thanks for your contribution!\n\n Hi Jack,\n\n Thank you very much for contributing to our open-source project! We really appreciate your help.\n\n Best regards,\n Zac\"\"\"\n\n# Create a secure SSL connection using port 465\nwith smtplib.SMTP_SSL('smtp.outlook.com', 465) as server:\n\n # Send the email with the composed message\n server.login(sender, 'your_password')\n server.sendmail(\n sender,\n recipient,\n message_body\n )\n\n\nNote that you will need to replace '[email protected]', 'your_password', and other placeholders with your actual email address and password. Also be sure to import any necessary modules or dependencies at the top of your script if they're not already imported."}]}}]}, "usage": {"input_tokens": 1241, "output_tokens": 242, "image_tokens": 180}}
Error making API request: To send an email via code, you can use various libraries such as smtplib in Python or JavaMail API in Java. Here's how you could do it using these tools:

Python:

import smtplib

def send_email():
    # Set up the sender and recipient addresses
    fromaddr = '[email protected]'
    toaddrs   = ['[email protected]']

    # Create the message content
    msg = """\
Subject: Thanks!

Dear Jack,

Thank you very much for your contributions to our open-source project! We appreciate your hard work.

Best regards,
The Project Team"""

    try:
        # Connect to the SMTP server and send the mail
        smtpObj = smtplib.SMTP('smtp.example.com')
        smtpObj.sendmail(fromaddr, toaddrs, msg)
        print("Email sent successfully!")
    except Exception as e:
        print(f"Error occurred while sending email: {str(e)}")

send_email()

Java:

import javax.mail.*;
import java.util.Properties;

public class SendEmail {
    public static void main(String args[]) throws MessagingException {

        // Get system properties
        Properties props = System.getProperties();

        // Setup mail server
        String host = "smtp.example.com";
        props.put("mail.smtp.host", host);

        // Get the Session object
        Session session = Session.getDefaultInstance(props);

        try {
            // Create a default MimeMessage object.
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress("[email protected]"));
            message.addRecipient(Message.RecipientType.TO, new InternetAddress("[email protected]"));

            // Set the subject and the body of the message
            message.setSubject("Thanks!");
            message.setText("Dear Jack,\n\nThank you very much for your contributions to our open-source project!\nWe appreciate your hard work.\n\nBest regards," +
                    "\nThe Project Team");

            // Send the actual email with the message through the transport service
            Transport.send(message);
            System.out.println("Email sent successfully!");

        } catch (MessagingException mex) {
            throw new RuntimeException(mex);
        }
    }
}

Please replace [email protected], [email protected], and smtp.example.com with appropriate values before running this script. Also note that some parts may vary depending on which programming language/library you choose to implement this functionality.
{"status_code": 200, "request_id": "d58465d5-11ba-9009-93fc-bb682810236c", "code": "", "message": "", "output": {"text": null, "finish_reason": null, "choices": [{"finish_reason": "stop", "message": {"role": "assistant", "content": [{"text": "To send an email via code, you can use various libraries such as smtplib in Python or JavaMail API in Java. Here's how you could do it using these tools:\n\nPython:\npython\nimport smtplib\n\ndef send_email():\n # Set up the sender and recipient addresses\n fromaddr = '[email protected]'\n toaddrs = ['[email protected]']\n\n # Create the message content\n msg = \"\"\"\\\nSubject: Thanks!\n\nDear Jack,\n\nThank you very much for your contributions to our open-source project! We appreciate your hard work.\n\nBest regards,\nThe Project Team\"\"\"\n\n try:\n # Connect to the SMTP server and send the mail\n smtpObj = smtplib.SMTP('smtp.example.com')\n smtpObj.sendmail(fromaddr, toaddrs, msg)\n print(\"Email sent successfully!\")\n except Exception as e:\n print(f\"Error occurred while sending email: {str(e)}\")\n\nsend_email()\n\nJava:\njava\nimport javax.mail.*;\nimport java.util.Properties;\n\npublic class SendEmail {\n public static void main(String args[]) throws MessagingException {\n\n // Get system properties\n Properties props = System.getProperties();\n\n // Setup mail server\n String host = \"smtp.example.com\";\n props.put(\"mail.smtp.host\", host);\n\n // Get the Session object\n Session session = Session.getDefaultInstance(props);\n\n try {\n // Create a default MimeMessage object.\n Message message = new MimeMessage(session);\n message.setFrom(new InternetAddress(\"[email protected]\"));\n message.addRecipient(Message.RecipientType.TO, new InternetAddress(\"[email protected]\"));\n\n // Set the subject and the body of the message\n message.setSubject(\"Thanks!\");\n message.setText(\"Dear Jack,\\n\\nThank you very much for your contributions to our open-source project!\\nWe appreciate your hard work.\\n\\nBest regards,\" +\n \"\\nThe Project Team\");\n\n // Send the actual email with the message through the transport service\n Transport.send(message);\n System.out.println(\"Email sent successfully!\");\n\n } catch (MessagingException mex) {\n throw new RuntimeException(mex);\n }\n }\n}\n\n\nPlease replace [email protected], [email protected], and smtp.example.com with appropriate values before running this script. Also note that some parts may vary depending on which programming language/library you choose to implement this functionality."}]}}]}, "usage": {"input_tokens": 1241, "output_tokens": 496, "image_tokens": 180}}
Error occurs when calling LLM: Traceback (most recent call last):
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\module\processors\processor.py", line 165, in get_response
self._response, self._cost = self.host_agent.get_response(
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\agent\basic.py", line 278, in get_response
response_string, cost = llm_call.get_completion(
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\llm\llm_call.py", line 33, in get_completion
return responses[0], cost
IndexError: list index out of range

Traceback (most recent call last):
File "D:\ProgramFiles\anaconda3\envs\UFO\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "D:\ProgramFiles\anaconda3\envs\UFO\lib\runpy.py", line 86, in run_code
exec(code, run_globals)
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo_main
.py", line 7, in
ufo.main()
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\ufo.py", line 55, in main
clients.run_all()
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\module\client.py", line 52, in run_all
client.run()
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\module\client.py", line 28, in run
self.session.handle()
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\module\basic.py", line 459, in handle
self._state.handle(self)
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\module\state.py", line 194, in handle
session.round_hostagent_execution()
File "D:\Projects\GithubProjects\UFO-v0.1.1\ufo\module\session.py", line 224, in round_hostagent_execution
self.application = self.app_window.window_text()
AttributeError: 'NoneType' object has no attribute 'window_text'

Lenguaje dominante
Python
Estrellas
10.2k
Forks
1.1k
Merge medio
1 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de microsoft/UFO

Todos los issues de microsoft/UFO

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.