Skip to content

Commit

Permalink
Merge pull request #41 from LyzrCore/feat/summarizer-generator
Browse files Browse the repository at this point in the history
refactor: ♻️ Changed parameter "style" to "Instructions"
  • Loading branch information
praveenlyzr authored Apr 25, 2024
2 parents 334d220 + c974385 commit ae21f4f
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 70 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ tests/
testing/
logs/
*.log
.vscode/
.vscode/
22 changes: 10 additions & 12 deletions build/lib/lyzr/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ def generate(
self,
text:str,
persona: Optional[str] = "Not Specified",
style: Optional[str] = "Short Story" #Could be a Poem, a Children's story or even a tweet
instructions: Optional[str] = "Short Story" #Could be a Poem, a Children's story or even a tweet
) -> str:
'''
Generates content in various styles such as a children's story, a poem, or even a tweet from the provided text using OpenAI's GPT-4 model. This function is designed to expand a byte sized prompt into a more elaborate format, according to the specified style.
Generates content in various styles such as a children's story, a poem, or even a tweet from the provided text using OpenAI's GPT-4 model. This function is designed to expand a byte sized prompt into a more elaborate format, according to the specified instructions.
Parameters:
- `text` (str): The substantial text or conversation input that needs to be elaborated or expanded.
- `persona` (Optional[str], default = "Not Specified"): Specifies the persona or audience for which the content is tailored. This parameter helps in customizing the tone and style of the generated content to better resonate with the intended audience.
- `style` (Optional[str], default = "Mini Essay"): Specifies the type of output desired. Options include "Mini Essay" for a detailed narrative, "Poem" for poetic content, "Children's Story" for content suitable for children, or "Tweet" for extremely concise content suitable for social media platforms like Twitter. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
- `instructions` (Optional[str], default = "Short Story"): Specifies the type of output desired. Options include "Mini Essay" for a detailed narrative, "Poem" for poetic content, "Children's Story" for content suitable for children, or "Tweet" for extremely concise content suitable for social media platforms like Twitter. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
Return:
Expand All @@ -50,12 +50,12 @@ def generate(
# Provide the text to be condensed and specify the desired style
text = "Prompt or idea that you want to expand upon"
story = generator.generate(text, style='story')
story = generator.generate(text, instructions='story')
print(story)
# You can also specify the persona for which the content is tailored
persona = "Tech Enthusiasts"
condensed_content = generator.generate(text, persona=persona, style='Tweet')
condensed_content = generator.generate(text, persona=persona, instructions='Tweet')
print(condensed_content)
```
Expand All @@ -70,14 +70,15 @@ def generate(
)
else:
raise ValueError(
"The text_to_notes function only works with the OpenAI's 'gpt-4' model."
"This function only works with the OpenAI's 'gpt-4' model."
)

# The system message acts as the prompt for the AI.
system_message = f'''You are an Expert CONTENT CREATOR. Your task is to DEVELOP a VARIETY of TEXT-BASED CONTENT that could range from BLOGS to TWEETS.
Persona of the content: {persona}
Style of the content: {style}
The target audience of the content: {persona}
The Format of the content should be based on these instructions: {instructions}
Here's how you can approach this task:
Expand All @@ -88,10 +89,7 @@ def generate(
5. WRITE the initial draft focusing on ENGAGEMENT and VALUE delivery for your readers or followers.
6. EMPLOY a conversational tone or formal style according to the platform and type of content you are creating.
7. EDIT and REVISE your work to enhance CLARITY, GRAMMAR, and COHERENCE before publishing.
You MUST maintain CONSISTENCY in quality across all platforms and types of content.
Remember, I’m going to tip $300K for a BETTER SOLUTION!
8. DON'T display anything that is not relevant to the content such as comments or instructions.
Now Take a Deep Breath.'''

Expand Down
21 changes: 9 additions & 12 deletions build/lib/lyzr/summarizer/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def __init__(
def summarize(
self,
text:str,
style: Optional[str] = "Summary" #Could be summary or notes or even a tweet
instructions: Optional[str] = "Summary" #Could be summary or notes or even a tweet
) -> str:
'''
Generates a concise summary or notes from the provided text using a preconfigured Large Language Model (LLM), specifically targeting OpenAI's GPT-4 model. This function is designed to streamline extensive paragraphs or conversations into a more digestible format, according to the specified style. It internally configures a detailed instruction set for the AI, ensuring the output captures all critical information while omitting superfluous details.
Generates a concise summary or notes from the provided text using a preconfigured Large Language Model (LLM), specifically targeting OpenAI's GPT-4 model. This function is designed to streamline extensive paragraphs or conversations into a more digestible format, according to the specified instructions. It internally configures a detailed instruction set for the AI, ensuring the output captures all critical information while omitting superfluous details.
Parameters:
- `text` (str): The substantial text or conversation input that needs to be summarized or condensed.
- `style` (Optional[str], default = "Summary"): Specifies the type of output desired. Options include "Summary" for a straightforward summarization, "Notes" for a bullet-point or outlined form, or custom styles such as a "Tweet" for extremely concise content. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
- `instructions` (Optional[str], default = "Summary"): Specifies the type of output desired. Options include "Summary" for a straightforward summarization, "Notes" for a bullet-point or outlined form, or custom instructions such as a "Tweet" for extremely concise content. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
Return:
Expand All @@ -47,12 +47,12 @@ def summarize(
summary = summarizer.summarize(text)
print(summary)
# Or for a different style
notes = summarizer.summarize(text, style='Notes')
# Or for a different format:
notes = summarizer.summarize(text, instructions='Notes')
print(notes)
```
This functionality leverages advanced language model capabilities for creating succinct and accurate representations of larger bodies of text, adjustable to various output styles for enhanced utility in information processing and content creation scenarios.
This functionality leverages advanced language model capabilities for creating succinct and accurate representations of larger bodies of text, adjustable to various output instructions for enhanced utility in information processing and content creation scenarios.
'''
if self.model.model_name != "gpt-4":
if self.model.model_type == "openai":
Expand All @@ -63,13 +63,13 @@ def summarize(
)
else:
raise ValueError(
"The text_to_notes function only works with the OpenAI's 'gpt-4' model."
"This function only works with the OpenAI's 'gpt-4' model."
)

# The system message acts as the prompt for the AI.
system_message = f'''You are an Expert SUMMARIZER with a keen ability to CAPTURE ESSENTIAL DETAILS from extensive conversations. Your task is to CREATE a CONCISE SUMMARY of the given content, ensuring that ALL CRITICAL INFORMATION is included.
The style of the summary should be: {style}
The Format of the summary should be based on these instructions: {instructions}
Here's your step-by-step guide:
Expand All @@ -78,10 +78,7 @@ def summarize(
3. ORGANIZE these points into a LOGICAL STRUCTURE that reflects the progression of the conversation.
4. WRITE a CLEAR and COHERENT summary that seamlessly integrates all significant details without superfluous information.
5. REVIEW your summary to VERIFY that it accurately represents the original conversation and includes all pertinent data.
You MUST ensure that no important detail is left out from your summary.
Remember, Im going to tip $300K for a BETTER SOLUTION!
6. DON'T display anything that is not relevant to the summary such as comments or instructions.
Now Take a Deep Breath.'''

Expand Down
Binary file removed dist/lyzr-0.1.35-py3-none-any.whl
Binary file not shown.
Binary file removed dist/lyzr-0.1.35.tar.gz
Binary file not shown.
Binary file added dist/lyzr-0.1.36-py3-none-any.whl
Binary file not shown.
Binary file added dist/lyzr-0.1.36.tar.gz
Binary file not shown.
9 changes: 2 additions & 7 deletions lyzr.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
Metadata-Version: 2.1
Name: lyzr
Version: 0.1.35
Summary: UNKNOWN
Home-page: UNKNOWN
Version: 0.1.36
Home-page:
Author: lyzr
License: UNKNOWN
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Expand Down Expand Up @@ -165,5 +162,3 @@ response = chatbot.chat("Your question here")
## License

`lyzr` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.


26 changes: 13 additions & 13 deletions lyzr.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
asyncio
beautifulsoup4==4.12.2
langchain==0.0.339
litellm==1.2.0
llama-index==0.9.4
llmsherpa
matplotlib==3.8.2
nest_asyncio
openai==1.3.4
pandas==2.0.2
litellm==1.2.0
llama-index==0.9.4
langchain==0.0.339
python-dotenv>=1.0.0
beautifulsoup4==4.12.2
pandas==2.0.2
weaviate-client==3.25.3
llmsherpa
matplotlib==3.8.2

[data-analyzr]
scikit-learn==1.4.0
statsmodels==0.14.1
chromadb==0.4.22
mysql-connector-python==8.2.0
openpyxl==3.1.2
tabulate==0.9.0
pmdarima==2.0.4
psycopg2-binary==2.9.9
openpyxl==3.1.2
redshift_connector==2.0.918
scikit-learn==1.4.0
mysql-connector-python==8.2.0
psycopg2-binary==2.9.9
snowflake-connector-python==3.6.0
statsmodels==0.14.1
tabulate==0.9.0
22 changes: 10 additions & 12 deletions lyzr/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ def generate(
self,
text:str,
persona: Optional[str] = "Not Specified",
style: Optional[str] = "Short Story" #Could be a Poem, a Children's story or even a tweet
instructions: Optional[str] = "Short Story" #Could be a Poem, a Children's story or even a tweet
) -> str:
'''
Generates content in various styles such as a children's story, a poem, or even a tweet from the provided text using OpenAI's GPT-4 model. This function is designed to expand a byte sized prompt into a more elaborate format, according to the specified style.
Generates content in various styles such as a children's story, a poem, or even a tweet from the provided text using OpenAI's GPT-4 model. This function is designed to expand a byte sized prompt into a more elaborate format, according to the specified instructions.
Parameters:
- `text` (str): The substantial text or conversation input that needs to be elaborated or expanded.
- `persona` (Optional[str], default = "Not Specified"): Specifies the persona or audience for which the content is tailored. This parameter helps in customizing the tone and style of the generated content to better resonate with the intended audience.
- `style` (Optional[str], default = "Mini Essay"): Specifies the type of output desired. Options include "Mini Essay" for a detailed narrative, "Poem" for poetic content, "Children's Story" for content suitable for children, or "Tweet" for extremely concise content suitable for social media platforms like Twitter. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
- `instructions` (Optional[str], default = "Short Story"): Specifies the type of output desired. Options include "Mini Essay" for a detailed narrative, "Poem" for poetic content, "Children's Story" for content suitable for children, or "Tweet" for extremely concise content suitable for social media platforms like Twitter. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
Return:
Expand All @@ -50,12 +50,12 @@ def generate(
# Provide the text to be condensed and specify the desired style
text = "Prompt or idea that you want to expand upon"
story = generator.generate(text, style='story')
story = generator.generate(text, instructions='story')
print(story)
# You can also specify the persona for which the content is tailored
persona = "Tech Enthusiasts"
condensed_content = generator.generate(text, persona=persona, style='Tweet')
condensed_content = generator.generate(text, persona=persona, instructions='Tweet')
print(condensed_content)
```
Expand All @@ -70,14 +70,15 @@ def generate(
)
else:
raise ValueError(
"The text_to_notes function only works with the OpenAI's 'gpt-4' model."
"This function only works with the OpenAI's 'gpt-4' model."
)

# The system message acts as the prompt for the AI.
system_message = f'''You are an Expert CONTENT CREATOR. Your task is to DEVELOP a VARIETY of TEXT-BASED CONTENT that could range from BLOGS to TWEETS.
Persona of the content: {persona}
Style of the content: {style}
The target audience of the content: {persona}
The Format of the content should be based on these instructions: {instructions}
Here's how you can approach this task:
Expand All @@ -88,10 +89,7 @@ def generate(
5. WRITE the initial draft focusing on ENGAGEMENT and VALUE delivery for your readers or followers.
6. EMPLOY a conversational tone or formal style according to the platform and type of content you are creating.
7. EDIT and REVISE your work to enhance CLARITY, GRAMMAR, and COHERENCE before publishing.
You MUST maintain CONSISTENCY in quality across all platforms and types of content.
Remember, I’m going to tip $300K for a BETTER SOLUTION!
8. DON'T display anything that is not relevant to the content such as comments or instructions.
Now Take a Deep Breath.'''

Expand Down
21 changes: 9 additions & 12 deletions lyzr/summarizer/summarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ def __init__(
def summarize(
self,
text:str,
style: Optional[str] = "Summary" #Could be summary or notes or even a tweet
instructions: Optional[str] = "Summary" #Could be summary or notes or even a tweet
) -> str:
'''
Generates a concise summary or notes from the provided text using a preconfigured Large Language Model (LLM), specifically targeting OpenAI's GPT-4 model. This function is designed to streamline extensive paragraphs or conversations into a more digestible format, according to the specified style. It internally configures a detailed instruction set for the AI, ensuring the output captures all critical information while omitting superfluous details.
Generates a concise summary or notes from the provided text using a preconfigured Large Language Model (LLM), specifically targeting OpenAI's GPT-4 model. This function is designed to streamline extensive paragraphs or conversations into a more digestible format, according to the specified instructions. It internally configures a detailed instruction set for the AI, ensuring the output captures all critical information while omitting superfluous details.
Parameters:
- `text` (str): The substantial text or conversation input that needs to be summarized or condensed.
- `style` (Optional[str], default = "Summary"): Specifies the type of output desired. Options include "Summary" for a straightforward summarization, "Notes" for a bullet-point or outlined form, or custom styles such as a "Tweet" for extremely concise content. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
- `instructions` (Optional[str], default = "Summary"): Specifies the type of output desired. Options include "Summary" for a straightforward summarization, "Notes" for a bullet-point or outlined form, or custom instructions such as a "Tweet" for extremely concise content. This parameter influences the instruction set given to the AI, tailoring its approach to content generation.
Return:
Expand All @@ -47,12 +47,12 @@ def summarize(
summary = summarizer.summarize(text)
print(summary)
# Or for a different style
notes = summarizer.summarize(text, style='Notes')
# Or for a different format:
notes = summarizer.summarize(text, instructions='Notes')
print(notes)
```
This functionality leverages advanced language model capabilities for creating succinct and accurate representations of larger bodies of text, adjustable to various output styles for enhanced utility in information processing and content creation scenarios.
This functionality leverages advanced language model capabilities for creating succinct and accurate representations of larger bodies of text, adjustable to various output instructions for enhanced utility in information processing and content creation scenarios.
'''
if self.model.model_name != "gpt-4":
if self.model.model_type == "openai":
Expand All @@ -63,13 +63,13 @@ def summarize(
)
else:
raise ValueError(
"The text_to_notes function only works with the OpenAI's 'gpt-4' model."
"This function only works with the OpenAI's 'gpt-4' model."
)

# The system message acts as the prompt for the AI.
system_message = f'''You are an Expert SUMMARIZER with a keen ability to CAPTURE ESSENTIAL DETAILS from extensive conversations. Your task is to CREATE a CONCISE SUMMARY of the given content, ensuring that ALL CRITICAL INFORMATION is included.
The style of the summary should be: {style}
The Format of the summary should be based on these instructions: {instructions}
Here's your step-by-step guide:
Expand All @@ -78,10 +78,7 @@ def summarize(
3. ORGANIZE these points into a LOGICAL STRUCTURE that reflects the progression of the conversation.
4. WRITE a CLEAR and COHERENT summary that seamlessly integrates all significant details without superfluous information.
5. REVIEW your summary to VERIFY that it accurately represents the original conversation and includes all pertinent data.
You MUST ensure that no important detail is left out from your summary.
Remember, Im going to tip $300K for a BETTER SOLUTION!
6. DON'T display anything that is not relevant to the summary such as comments or instructions.
Now Take a Deep Breath.'''

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name="lyzr",
version="0.1.35",
version="0.1.36",
author="lyzr",
description="",
long_description=open("README.md").read(),
Expand Down

0 comments on commit ae21f4f

Please sign in to comment.