Skip to content

Add generate_text usage example#767

Open
himanshigaba22 wants to merge 3 commits into
thoth-tech:mainfrom
himanshigaba22:generate-text-usage-example
Open

Add generate_text usage example#767
himanshigaba22 wants to merge 3 commits into
thoth-tech:mainfrom
himanshigaba22:generate-text-usage-example

Conversation

@himanshigaba22
Copy link
Copy Markdown

Description

Adds usage example for the generate_text function from SplashKit Generative AI API.

Type of Change

  • New usage example

Usage Example Details

  • Function: generate_text
  • Category: generative_ai
  • Files added:
    • generate_text-1-example.cpp
    • generate_text-1-example-top-level.cs
    • generate_text-1-example-oop.cs
    • generate_text-1-example.py
    • generate_text-1-example.txt
    • generate_text-1-example.png

Checklist

  • All 6 files created with correct names
  • Code tested and runs correctly
  • Screenshot shows output only
  • Files placed in correct folder

@netlify
Copy link
Copy Markdown

netlify Bot commented May 12, 2026

Deploy Preview for splashkit failed.

Name Link
🔨 Latest commit 7ccf6f1
🔍 Latest deploy log https://app.netlify.com/projects/splashkit/deploys/6a0583676c7c110008246975

Copy link
Copy Markdown

@ralphweng2023 ralphweng2023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code's clean and easy to follow, four files line up logic-wise and the function is used as advertised. Couple of small things before this can merge:

  • The OOP .cs file is missing the namespace GenerateTextExample wrapper that other OOP examples use (see section 5 of the project's usage-example style guide, or similar examples under other categories). Also Main(string[] args)Main(). Granted there's not a lot of "OOP" to show for a single static call, but worth matching the template so it stays consistent with the rest of the repo.
  • All five text files end without a trailing newline (the diff shows \ No newline at end of file for each). Small thing, easy to fix on re-save.

One question — does generate_text(prompt) work straight out of the box, or is there some model-loading / API-key step the user needs to set up first? If there's background setup, might be worth a one-liner comment in the code so a beginner with a blank response doesn't think it's broken.

Otherwise once those are sorted should be good to go.

Copy link
Copy Markdown

@jankiluitel jankiluitel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the generate_text usage example PR. The implementation is clean, concise, and consistent across all supported languages. The example clearly demonstrates how to use the GenerateText functionality with simple beginner-friendly prompts and readable output formatting.

The included screenshot/example asset also supports the documentation well. Everything looks aligned with existing SplashKit usage example standards from my side.

Copy link
Copy Markdown

@222448082Ashen 222448082Ashen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Peer Review

I've reviewed the generate_text usage example.

Checks

  • All required files present (title, C++, C# top-level, C# OOP, Python, screenshot)
  • Code uses the documented SplashKit API (generate_text(string))
  • Example clearly demonstrates
  • Cross-language implementations maintain matching structure and comments

Code Tests done

  • C++ example validated
  • C# top-level validated
  • C# OOP validated (suggest minor style tweak)
  • Python example validated

Website Tests done

  • npm run build (examples scraped and MDX generated)
  • npm run preview (local preview runs; site config may warn)

@himanshigaba22
Copy link
Copy Markdown
Author

Code's clean and easy to follow, four files line up logic-wise and the function is used as advertised. Couple of small things before this can merge:

  • The OOP .cs file is missing the namespace GenerateTextExample wrapper that other OOP examples use (see section 5 of the project's usage-example style guide, or similar examples under other categories). Also Main(string[] args)Main(). Granted there's not a lot of "OOP" to show for a single static call, but worth matching the template so it stays consistent with the rest of the repo.
  • All five text files end without a trailing newline (the diff shows \ No newline at end of file for each). Small thing, easy to fix on re-save.

One question — does generate_text(prompt) work straight out of the box, or is there some model-loading / API-key step the user needs to set up first? If there's background setup, might be worth a one-liner comment in the code so a beginner with a blank response doesn't think it's broken.

Otherwise once those are sorted should be good to go.

Hi! I have addressed all the feedback:

  • Added namespace GenerateTextExample wrapper to OOP file
  • Changed Main(string[] args) to Main()
  • Added a comment in all files noting that a local AI
    model is required via SplashKit
  • Fixed trailing newlines in all files

Please let me know if anything else needs changing. Thank you!

Copy link
Copy Markdown

@ralphweng2023 ralphweng2023 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick turnaround. The OOP namespace wrap and Main() signature look good, and the "requires a local AI model" note in each language file is a nice touch — beginners running this with an empty response will know where to look.

One small thing the commit didn't quite catch: only the .txt actually got a trailing newline, the four code files (generate_text-1-example.cpp, .py, -top-level.cs, -oop.cs) still end without one. Not a blocker, just worth a quick re-save before merge.

@himanshigaba22
Copy link
Copy Markdown
Author

Thanks for the quick turnaround. The OOP namespace wrap and Main() signature look good, and the "requires a local AI model" note in each language file is a nice touch — beginners running this with an empty response will know where to look.

One small thing the commit didn't quite catch: only the .txt actually got a trailing newline, the four code files (generate_text-1-example.cpp, .py, -top-level.cs, -oop.cs) still end without one. Not a blocker, just worth a quick re-save before merge.

Hi! I have now added trailing newlines to all 4 code files.
Thank you for the thorough review and approval! 🙏

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

Successfully merging this pull request may close these issues.

5 participants