|
| 1 | +import type { WorkersAIModelsSchema } from "~/schemas"; |
| 2 | + |
| 3 | +const ModelFeatures = ({ model }: { model: WorkersAIModelsSchema }) => { |
| 4 | + const nf = new Intl.NumberFormat("en-US"); |
| 5 | + const properties: any = {}; |
| 6 | + model.properties.forEach((property: any) => { |
| 7 | + properties[property.property_id] = property.value; |
| 8 | + }); |
| 9 | + |
| 10 | + return ( |
| 11 | + <> |
| 12 | + {Object.keys(properties).length ? ( |
| 13 | + <> |
| 14 | + <table> |
| 15 | + <thead> |
| 16 | + <tr> |
| 17 | + <> |
| 18 | + <th>Features</th> |
| 19 | + <th /> |
| 20 | + </> |
| 21 | + </tr> |
| 22 | + </thead> |
| 23 | + <tbody> |
| 24 | + {properties.planned_deprecation_date && ( |
| 25 | + <tr> |
| 26 | + <td> |
| 27 | + {Date.now() > |
| 28 | + Math.floor( |
| 29 | + new Date(properties.planned_deprecation_date).getTime() / |
| 30 | + 1000, |
| 31 | + ) |
| 32 | + ? "Deprecated" |
| 33 | + : "Planned Deprecation"} |
| 34 | + </td> |
| 35 | + <td> |
| 36 | + {new Date( |
| 37 | + properties.planned_deprecation_date, |
| 38 | + ).toLocaleDateString("en-US")} |
| 39 | + </td> |
| 40 | + </tr> |
| 41 | + )} |
| 42 | + {properties.context_window && ( |
| 43 | + <tr> |
| 44 | + <td> |
| 45 | + Context Window |
| 46 | + <a href="/workers-ai/glossary/"> |
| 47 | + <span className="external-link"> ↗</span> |
| 48 | + </a> |
| 49 | + </td> |
| 50 | + <td>{nf.format(properties.context_window)} tokens</td> |
| 51 | + </tr> |
| 52 | + )} |
| 53 | + {properties.terms && ( |
| 54 | + <tr> |
| 55 | + <td>Terms and License</td> |
| 56 | + <td> |
| 57 | + <a href={properties.terms} target="_blank"> |
| 58 | + link<span className="external-link"> ↗</span> |
| 59 | + </a> |
| 60 | + </td> |
| 61 | + </tr> |
| 62 | + )} |
| 63 | + {properties.info && ( |
| 64 | + <tr> |
| 65 | + <td>More information</td> |
| 66 | + <td> |
| 67 | + <a href={properties.info} target="_blank"> |
| 68 | + link<span className="external-link"> ↗</span> |
| 69 | + </a> |
| 70 | + </td> |
| 71 | + </tr> |
| 72 | + )} |
| 73 | + {properties.max_input_tokens && ( |
| 74 | + <tr> |
| 75 | + <td>Maximum Input Tokens</td> |
| 76 | + <td>{nf.format(properties.max_input_tokens)}</td> |
| 77 | + </tr> |
| 78 | + )} |
| 79 | + {properties.output_dimensions && ( |
| 80 | + <tr> |
| 81 | + <td>Output Dimensions</td> |
| 82 | + <td>{nf.format(properties.output_dimensions)}</td> |
| 83 | + </tr> |
| 84 | + )} |
| 85 | + {properties.function_calling && ( |
| 86 | + <tr> |
| 87 | + <td> |
| 88 | + Function calling{" "} |
| 89 | + <a href="/workers-ai/function-calling"> |
| 90 | + <span className="external-link"> ↗</span> |
| 91 | + </a> |
| 92 | + </td> |
| 93 | + <td>Yes</td> |
| 94 | + </tr> |
| 95 | + )} |
| 96 | + {properties.lora && ( |
| 97 | + <tr> |
| 98 | + <td>LoRA</td> |
| 99 | + <td>Yes</td> |
| 100 | + </tr> |
| 101 | + )} |
| 102 | + {properties.beta && ( |
| 103 | + <tr> |
| 104 | + <td>Beta</td> |
| 105 | + <td>Yes</td> |
| 106 | + </tr> |
| 107 | + )} |
| 108 | + </tbody> |
| 109 | + </table> |
| 110 | + </> |
| 111 | + ) : ( |
| 112 | + false |
| 113 | + )} |
| 114 | + </> |
| 115 | + ); |
| 116 | +}; |
| 117 | + |
| 118 | +export default ModelFeatures; |
0 commit comments