This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This module demonstrates that it's possible to leverage WebAI to host an LLM chatbot, | |
| # interacting with it via APIs. The code sends a prompt to the LLM and streams back its response. | |
| # In theory, this approach can be extended to programmatically interact with the LLM, | |
| # while using WebAI to orchestrate running the LLM across a cluster of local hardware. | |
| # Demo: https://i.ibb.co/jkNF488Z/Feb-11-2025-12-17-22.gif | |
| import json | |
| import requests | |
| import time | |
| def get_endpoints(): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Controller from '@ember/controller'; | |
| export default class ApplicationController extends Controller { | |
| appName = 'Ember Twiddle'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Controller from '@ember/controller'; | |
| export default class ApplicationController extends Controller { | |
| appName = 'Ember Twiddle'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Controller from '@ember/controller'; | |
| export default class ApplicationController extends Controller { | |
| appName = 'Ember Twiddle'; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import Ember from 'ember'; | |
| import { debounce } from '@ember/runloop'; | |
| // This isnt totally necessary, but in the real world where an error.message might be really | |
| // long it might be better to reduce the stored key to something more consistant | |
| function hasher(str) { | |
| var hash = 0, i, chr; | |
| if (str.length === 0) return hash; | |
| for (i = 0; i < str.length; i++) { | |
| chr = str.charCodeAt(i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example of a class instantiation that is missing | |
| // required class constructor object properties | |
| import Person from 'person'; | |
| // Create a new person that is missing required object structures | |
| const jane = new Person ({ | |
| first: 'Jane', | |
| // Type Error! Property 'last' is missing | |
| // Type Error! Property 'geo' is missing | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example of a valid class instantiation that contains | |
| // all the required class constructor object properties | |
| import Person from 'person'; | |
| // Create a new person of the shape defined by our interfaces | |
| const john = new Person ({ | |
| first: 'John', | |
| last: 'Doe', | |
| geo: { | |
| country: 'USA', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface GeoInterface { | |
| state: string; | |
| country: string; | |
| } | |
| interface PersonInterface { | |
| first: string; | |
| last: string; | |
| // a Person must contain a 'geo' object that matches | |
| // the defined GeoInterface structure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // a 'Person' object requires 'first' and 'last' | |
| // properties whose values are strings | |
| interface Person { | |
| first: string; | |
| last: string; | |
| } | |
| // This defines that the first functional argument | |
| // must be an Array of 'Person' objects, then destructs | |
| // the first person's first and last name properties |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const person = { first: 'John', last: 'Doe' }; | |
| /* -- Correct TypeScript Functional Destructure -- */ | |
| // Define a 'Person' interface with the shape of | |
| // the expected Person object argument | |
| interface Person { | |
| first: string; | |
| last: string; | |
| } |
NewerOlder