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

Santizing inputs doesn't work on specific example #325

Closed
ilyashnil opened this issue Feb 21, 2024 · 4 comments
Closed

Santizing inputs doesn't work on specific example #325

ilyashnil opened this issue Feb 21, 2024 · 4 comments
Labels
question Further information is requested

Comments

@ilyashnil
Copy link

Version Information

  • Package Version:
    2.2.0
  • Operating System:
    MacOS

What is the expected behavior?

Generate text

What is the actual behavior?

Causes an exception:
{
“error”: “Bad Request”,
“extensions”: {
“code”: “INVALID_INPUT”,
“state”: null,
“reason”: “Unclosed tag at 3629"
},
“message”: “Input parsing error”,
“status_code”: 400
}

Please provide a unit test that demonstrates the bug.

"""
Simple text generation
"""

#from dotenv import load_dotenv

from genai.client import Client
from genai.credentials import Credentials
from genai.schema import (
TextGenerationParameters,
TextGenerationReturnOptions,
)

def heading(text: str) -> str:
"""Helper function for centering text."""
return "\n" + f" {text} ".center(80, "=") + "\n"

make sure you have a .env file under genai root with

GENAI_KEY=

GENAI_API=

#load_dotenv()
client = Client(credentials=Credentials.from_env())

print(heading("Simple Text Generation"))

yields batch of results that are produced asynchronously and in parallel

for response in client.text.generation.create(
model_id="google/flan-t5-xl",
inputs=["""
From: Thyagi@cup.portal.com (Thyagi Morgoth NagaSiva) Subject: Re: Ceci's "rosicrucian" adventure :-) Organization: The Portal System (TM) Distribution: world Lines: 112 930425 Tony Alicia writes: Let's start with the name "Rosicrucian". I took me a long time to come to the conclusion that there is a difference between a member of a "rosicrucian" body and BEING a ROSICRUCIAN. So when you say that you met some 'rosicrucians' you mean "members of a group that calls themselves rosicrucian". At least that is what your observation suggests :-) Response: This makes much sense to me. This is also true of most religions. There is a difference between being a member of a group of people who call themselves 'Hindus' or 'Christians' or 'Pagans' and actually BEING any of these. The social groups tend to make very important requirements about not belonging to other 'religions'. I find that the ideal described by the holy texts of most religions can be interpreted in very similar ways so that one could presume that 'mysticism' is the core of every religion and Huxley's 'Perennial Philosophy' is the Great Secret Core of all mystical trads. :> Tony: I'd prefer if you would have stated up front that it was the Lectorium Rosicrucianum, only because they may be confused, by some readers of this newsgroup, with the Rosicrucian Order AMORC based (the USA Jurisdiction) in San Jose, CA; this being the RC org with the most members (last time I looked). Of course, "most members" does not necessarily mean "best". Response: Certainly true. I didn't know there WERE any groups which called themselves 'Rosicrucians' that didn't associate with AMORC. Sure, I've heard all the hubbub about the Golden Dawn and Rosae Crucis in relation to all these Western esoteric groups, but hadn't heard about other 'Rosicrucians'. I'll admit my bias. I live in San Jose. :> Tony: "You'll have to trust me" when I tell you that if that lecture/class/whatever had been presented by AMORC, it is unlikely that you would have had the same impression, i.e., you'd probably have had a positive impression more likely than a negative one, IMHO. Response: This may be slightly off. I've met some of these Rosicrucians and have a couple friends in AMORC. The stories I've heard and the slight contact I've had with them does not give me the hope that I'd be received with any kind of warm welcome. I still like to think that most people who are involved with stratified relationships (monogamy, religion, etc.) are in DEEP pain and hope to heal it within such a 'cast'. Tony: It is curious to know that 3 other RC 'orders' (in the USA) claim to be non- sectarian. Response: I'd like to know at least the addresses of the 'other orders' which call themselves 'Rosicrucians' and especially those which are 'nonsectarian'. Is this 'nonsectarian' like the Masons, who require that a member 'believe in God by his/her definition'? Tony: I don't see nothing fundamentally wrong with "us containing something divine"... And yes I don't like phrases like "eternal bliss" either! :-) Response: Let alone us BEING something divine. ;> Tony: BTW, I have read the intro letters of the LRC which they will mail you free of charge. Response: Addresses, phone numbers of groups? I'm into networking. Thanks. | WILL \ | / LOVE \|// !! !! \|// ____|___________|@@| "Imagination is more important than knowledge." | | - Albert Einstein Thyagi / \ NagaSiva |()()| Thyagi@HouseofKAos.Abyss.com ^^^^^^/ House of KAoS -^^^^- 871 Ironwood Dr. ~~ San Jose, CA 95125-2815 'Fr.Nigris' on Divination Web Telnet seismo.soar.cs.cmu.edu 9393
"""],
parameters=TextGenerationParameters(
max_new_tokens=150,
min_new_tokens=20,
return_options=TextGenerationReturnOptions(
input_text=True,
),
),
):
result = response.results[0]
print(f"Input Text: {result.input_text}")
print(f"Generated Text: {result.generated_text}")
print("")

Other notes on how to reproduce the issue?

Any possible solutions?

It looks like removing {}}}{{{}/ from input string helps.

Can you identify the location in the GENAI source code where the problem exists?

No

If the bug is confirmed, would you be willing to submit a PR?

No
Yes / No (Help can be provided if you need assistance submitting a PR)

@ilyashnil
Copy link
Author

Discussion on Slack with code: https://ibm-research.slack.com/archives/C04BJ8YNQTS/p1708525018286339

@ilyashnil
Copy link
Author

It looks like the problem happens not only in python library but in curl too. The corresponding code can be found in slack: https://ibm-research.slack.com/archives/C04BJ8YNQTS/p1708525018286339

@Tomas2D Tomas2D added the question Further information is requested label Feb 29, 2024
@Tomas2D
Copy link
Member

Tomas2D commented Feb 29, 2024

The problem is related to the API. As soon as this gets fixed there, it will also work in the SDK.

@Tomas2D
Copy link
Member

Tomas2D commented Apr 24, 2024

@ilyashnil, can you verify that this issue is no longer a problem in the latest version (2.3.0)?

@Tomas2D Tomas2D closed this as completed May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants